fix(style): resolve ty type-checker issues in check-netbox scripts#583
Open
d3flex wants to merge 1 commit into
Open
fix(style): resolve ty type-checker issues in check-netbox scripts#583d3flex wants to merge 1 commit into
d3flex wants to merge 1 commit into
Conversation
- Use `sh.Command("ping")` instead of `from sh import ping` (sh uses
__getattr__ magic that ty cannot resolve statically)
- Move pynetbox model imports behind TYPE_CHECKING in machine-state.py;
possible because `from __future__ import annotations` makes all
annotations lazy — unused-machine-power.py lacks that import so dcim
must remain a runtime import there
- Fix `loglevel_to_int`: `/` returns float so ty rejects it as int;
switch to `//` and use `logging.ERROR` as getattr fallback to avoid None
- Suppress unresolved-import for netsnmp in pyproject.toml; netsnmp is
a C extension with no type stubs or py.typed marker
Issue: https://progress.opensuse.org/issues/191575
Signed-off-by: Ioannis Bonatakis <[email protected]>
6155a4d to
dd9d352
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sh.Command("ping")instead offrom sh import ping(sh uses getattr magic that ty cannot resolve statically)from __future__ import annotationsmakes all annotations lazy — unused-machine-power.py lacks that import so dcim must remain a runtime import thereloglevel_to_int:/returns float so ty rejects it as int; switch to//and uselogging.ERRORas getattr fallback to avoid NoneIssue: https://progress.opensuse.org/issues/191575