-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
New check: invalid-length-returned #845
Conversation
99cf39c
to
52c67a5
Compare
@@ -995,16 +995,22 @@ class SpecialMethodsChecker(BaseChecker): | |||
'invalid number of parameters. If it has too few or ' | |||
'too many, it might not work at all.', | |||
{'old_names': [('E0235', 'bad-context-manager')]}), | |||
'E0303': ('__len__ does not return non-negative integer', | |||
'bad-len-returned', |
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.
Can you rename this to negative-len-returned?
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.
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.
They will probably have different names, so that they can be easily disabled on a case by case basis. How about invalid-length-returned, does that sound better?
Thank you for this PR! looks good, I left a couple of comments with improvements that you can do. |
Thanks. Do you mind merging multiple commits or do you prefer having them squashed to single one? |
I don't mind having multiple commits, as long as they have good messages. |
52c67a5
to
9a78967
Compare
infered = _safe_infer_call_result(node, node) | ||
if infered is None or infered is astroid.util.Uninferable: | ||
return | ||
value = infered.value |
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.
infered might not always have a value, no? We can't guarantee it's always a Const value. Can you do add a test for this?
Implementation of issue pylint-dev#557.
9a78967
to
74512f1
Compare
New check: invalid-length-returned
Implementation of issue #557.