-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pylint part 2 #2339
Pylint part 2 #2339
Conversation
…g the way (0 instances)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious of the value of keeping the type hints in here if ultimately didn't solve the lint issue.
Maybe we should do __iter__
checks instead of is not None
?
Since Python doesn't do strict type enforcement at runtime maybe pylint is being overly pessimistic and wanting to see something like
if hasattr(self.relationships, '__iter__'):
I mean in the long run I would love to turn on
I'll give it a try. |
I tried |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Towards: #2292
What's Changed
Trying to keep these PRs a bit more manageable. :-) This one enables a few more of the highest-severity ("Error") pylint checkers and addresses them as described:
access-member-before-definition
and fix the 1 case it flagged (a minor if legitimate bug with a missing default value inUpdateObjectViewTestCase
)unsubscriptable-object
, no reports for this warning (probably got fixed along the way in the time since I initially set up the pylint configs)no-value-for-parameter
; it reported a few warnings in test code due to Pylint not innately understanding howunittest.mock.patch
works; fixed this by addingsignature-mutators
to the Pylint configuration.not-an-iterable
; 5 warnings reported, all of which appear to be false positives where we have an optional parameter defaulting to None and pylint not recognizing that we're guarding with aif parameter is not None
before trying to iterate over that parameter. I added type hints to these in hopes that it would get pylint to take the hint, but it appears not, so I added explicitpylint: disable
for each of these as well.invoke pylint --target nautobot.utilities.testing
,invoke pylint --target examples/example_plugin --recursive
.TODO