Skip to content

Complete models, or add type stubs #758

@AlexCK-STFC

Description

@AlexCK-STFC

pynetbox version

v7.6.1

NetBox version

v4.5

Feature type

Data model extension

Proposed functionality

Create stubs for models, for use with type checkers like mypy.

https://github.com/interdotlink/pynetbox-stubs did exist but has been archived/deprecated.
They point to https://github.com/koxudaxi/datamodel-code-generator but it seems this isn't alone a solution.

TraceableRecords, i.e. cables, can go between many object types.

And records like IpAddresses can be assigned to i.e. Devices or VMs. datamodel-code-generator alone can't work this out so just points to Any:

Image

https://github.com/interdotlink/pynetbox-stubs could be resurrected, but using datamodel-code-generator to stay up-to-date. Additional work will be needed, i.e. for TraceableRecords especially.

This may also be a chance to uplift Models and reduce the usage of generic Record types, i.e. for Racks.

Stubs would ultimately be unnecessary if complete models were generated; perhaps even allowing for changes to fit a specific API spec via a commandline tool.

Use case

There's currently no typing information available to type checkers for most properties:

Image

This would resolve that

External dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    app: pynetboxstatus: needs triageThe issue is awaiting triage by a maintainertype: featureIntroduction of new functionality to the application

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions