Fix examples for type of class Meta() #11827

Closed
opened 2025-12-29 21:50:22 +01:00 by adam · 1 comment
Owner

Originally created by @grische on GitHub (Nov 12, 2025).

Originally assigned to: @grische on GitHub.

Change Type

Correction

Area

Customization

Proposed Changes

The current examples of using class Meta: should be class Meta(Script.Meta): to use the correct type when overriding.

See the error:

"Meta" overrides symbol of same name in class "BaseScript"
  "netbox.scripts.scripts.sample_script.MyScript.Meta" is not assignable to "netbox.extras.scripts.BaseScript.Meta"
  Type "type[netbox.scripts.scripts.sample_script.MyScript.Meta]" is not assignable to type "type[netbox.extras.scripts.BaseScript.Meta]"

from Pylance reportIncompatibleVariableOverride

The suggested change is:

diff --git a/docs/customization/custom-scripts.md b/docs/customization/custom-scripts.md
index 936dfd868..15d6c81f0 100644
--- a/docs/customization/custom-scripts.md
+++ b/docs/customization/custom-scripts.md
@@ -95,7 +95,7 @@ An example fieldset definition is provided below:

 ```python
 class MyScript(Script):
-    class Meta:
+    class Meta(Script.Meta):
         fieldsets = (
             ('First group', ('field1', 'field2', 'field3')),
             ('Second group', ('field4', 'field5')),
@@ -510,7 +510,7 @@ from extras.scripts import *

 class NewBranchScript(Script):

-    class Meta:
+    class Meta(Script.Meta):
         name = "New Branch"
         description = "Provision a new branch site"
         field_order = ['site_name', 'switch_count', 'switch_model']

I have prepared the PR but I noticed that I needed to open an issue first.

Originally created by @grische on GitHub (Nov 12, 2025). Originally assigned to: @grische on GitHub. ### Change Type Correction ### Area Customization ### Proposed Changes The current examples of using `class Meta:` should be `class Meta(Script.Meta):` to use the correct type when overriding. See the error: ``` "Meta" overrides symbol of same name in class "BaseScript" "netbox.scripts.scripts.sample_script.MyScript.Meta" is not assignable to "netbox.extras.scripts.BaseScript.Meta" Type "type[netbox.scripts.scripts.sample_script.MyScript.Meta]" is not assignable to type "type[netbox.extras.scripts.BaseScript.Meta]" ``` from Pylance [reportIncompatibleVariableOverride](https://github.com/microsoft/pylance-release/blob/main/docs/diagnostics/reportIncompatibleVariableOverride.md) The suggested change is: ```diff diff --git a/docs/customization/custom-scripts.md b/docs/customization/custom-scripts.md index 936dfd868..15d6c81f0 100644 --- a/docs/customization/custom-scripts.md +++ b/docs/customization/custom-scripts.md @@ -95,7 +95,7 @@ An example fieldset definition is provided below: ```python class MyScript(Script): - class Meta: + class Meta(Script.Meta): fieldsets = ( ('First group', ('field1', 'field2', 'field3')), ('Second group', ('field4', 'field5')), @@ -510,7 +510,7 @@ from extras.scripts import * class NewBranchScript(Script): - class Meta: + class Meta(Script.Meta): name = "New Branch" description = "Provision a new branch site" field_order = ['site_name', 'switch_count', 'switch_model'] ``` I have prepared the PR but I noticed that I needed to open an issue first.
adam added the status: acceptedtype: documentationnetbox labels 2025-12-29 21:50:22 +01:00
adam closed this issue 2025-12-29 21:50:22 +01:00
Author
Owner

@grische commented on GitHub (Nov 13, 2025):

@arthanson not sure if you missed my message above, but I have a PR ready, just need to be assigned the issue.

@grische commented on GitHub (Nov 13, 2025): @arthanson not sure if you missed my message above, but I have a PR ready, just need to be assigned the issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11827