-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
unidiomatic-typecheck to check right-hand side too #10225
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
unidiomatic-typecheck to check right-hand side too #10225
Conversation
|
Thanks for pitching in with this one. There are a couple test failures to look into. We will also want a simple addition to the functional test in |
This comment was marked as resolved.
This comment was marked as resolved.
Codecov ReportAll modified and coverable lines are covered by tests β
Additional details and impacted files@@ Coverage Diff @@
## main #10225 +/- ##
=======================================
Coverage 95.84% 95.84%
=======================================
Files 175 175
Lines 19056 19058 +2
=======================================
+ Hits 18264 18266 +2
Misses 792 792
π New features to boost your workflow:
|
Pierre-Sassoulas
left a comment
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.
Looks great already ! I have a question :)
| left = node.left | ||
| if _is_one_arg_pos_call(left): | ||
| self._check_type_x_is_y(node, left, operator, right) | ||
| elif isinstance(left, nodes.Name) and _is_one_arg_pos_call(right): |
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.
If I understand correctly the first condition is to avoid to analyse thing like "X" is type(...), right ? Why is this a problem ?
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.
Some tests were failing without this condition. So, I have added it.
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.
Ok ! I think the check still make sense in this case so it's better to disable unidiomatic-typecheck in the affected functional tests (add a disable comment at the top of the file, or preferably on an existing line so not everything is modified in the expected output), or add the new expected message on the affected line with # [unidiomatic-typecheck]. The functional test are not very independent this kind of things happen when we fix a false negative or introduce a new check.
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.
All tests run fine now. So, I think it is better not to touch the functional tests even to disable unidiomatic-typecheck.
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.
If I understand correctly the first condition is to avoid to analyse thing like "X" is type(...), right ?
I think it's not just string literals but almost any ast node. I think there's value in keeping this bugfix scoped small, esp as a "good first issue", but that's my 2c.
For string literals, I guess I'd expect any usage of is to have a lint warning, to resemble the runtime warning you get from python:
SyntaxWarning: "is" with 'str' literal.
|
Thanks for the first contribution, welcome aboard! |
Type of Changes
Description
Closes #10217