Support class-level record_input defaults for custom variable types

Open Beginner friendly
#244 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start by reading the ScriptVariable implementation and the existing class-level field_attrs handling to locate how defaults are inherited during instantiation. Check the tests for variable initialization and input recording, then add coverage for a subclass default and explicit True or False overrides. Done means the type default applies only when no policy is supplied and existing privacy safeguards still pass.

Written by the indexing model from the issue text.

Description

app: scripts Bucket: Improve complexity: low status: backlog type: feature
Plugin Version

v0.2.0

Proposed functionality

Allow custom ScriptVariable subclasses to define record_input at class level.

When no explicit recording policy is provided during instantiation, the variable should inherit its type's default. An explicitly supplied True or False should take precedence, while existing privacy safeguards remain unchanged.

This would be consistent with the existing support for class-level field_attrs.

Use case

Script authors may define reusable variable types for sensitive inputs, such as PINs or access codes:

class SecretVar(IntegerVar):
    record_input = False

This would allow authors to exclude such values from the recorded input summary by default, without having to specify record_input=False for every declaration.

External dependencies

None.

Dominant language
Python
Stars
9
Forks
0
Avg merge
18h 59m
Merged PRs (30d)
93

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from netbox-community/netbox-scripts

All issues in netbox-community/netbox-scripts

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.