-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fixes duplicate-code check with ignore-imports #9147
Fixes duplicate-code check with ignore-imports #9147
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #9147 +/- ##
=======================================
Coverage 95.76% 95.76%
=======================================
Files 173 173
Lines 18680 18681 +1
=======================================
+ Hits 17889 17890 +1
Misses 791 791
|
This comment has been minimized.
This comment has been minimized.
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.
Thanks for the patch!
Inference seems like overkill here, since we just need to traverse the ast. Something like this passes the unit test you've contributed. It causes a failure in test_no_hide_code_with_imports
, but that puzzles me as that expected result looks incorrect (we should remove the --ignore-imports
flag from that case, no?
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
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.
Thanks for the updates; very helpful. Requesting one last test case to pass and then this should be ready to merge!
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
π€ According to the primer, this change has no effect on the checked open source code. π€π This comment was generated for commit c5cbe23 |
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.
Thanks for the contribution!
Sure, thank you for the extensive review and suggestions. |
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.
We're not checking duplicate-code
in the primers, might be beneficial to check locally or exceptionally/temporarily enable it in the CI in this case ? (wdyt @jacobtylerwalls ?)
Yeah, that's worth a try. |
I ran the primer locally, minus I did see a handful of wanted changes like this: No longer emitted: (astroid) |
(Just clarifying for folks who might not be aware of the flakiness in the primer checks: the "noisy, trivial output" I referred to is probably from some unrelated mutability of cached objects in astroid, not from anything wrong in this PR.) |
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com> (cherry picked from commit 67f20bd)
Thank you for checking Jacob ! |
Type of Changes
Description
Improves detection of imports under conditionals.
Limited checks by constant conditions such asTrue
/typing.TYPE_CHECKING
.Closes #8914