-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
Iterate over Keywords when using ClassDef.get_children #919
Conversation
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.
Nice fix, but could we had a little test case ? The example in pylint-dev/pylint#3202 seems on point.
feaa011
to
a5eaaee
Compare
@Pierre-Sassoulas I agree, but isn't that a pylint test? I plan to add that case to pylint anyway later, especially since I'll need to fix a pylint issue as a result of this MR. from test_unused_import_const import DOMAIN
class Child:
def __init_subclass__(cls, domain, **kwargs):
pass
class Parent(Child, domain=DOMAIN):
DOMAIN = DOMAIN # add this line
pass After |
I think it's better if the faulty change in astroid are caught before they're merged in astroid's master. Of course the pylint test would catch it later but it's more complicated to fix, we'll have to create two issues and another MR in astroid instead of just fixing astroid's test in the base MR in the first place. |
I'm not sure I fully understand what you meant. The MR itself is fine. Anyway, without a followup (the one I'm working on at the moment), we are trading a common false-positive against an uncommon one which can be fixed. |
You're right we can't use the pylint example directly as a test. I think that a small test checking that we're getting the keyword when iterating on |
Added that one with the last commit: 973e22e -- I have the fix for pylint finished already. Just need to do and write some more tests. Maybe hold off on merging until I open the pylint MR? |
@cdce8p i began to have a look at it today but won t have time to finish before next week end at best. |
@hippo91 In class definitions it's possible to pass additional keyword arguments along that should be handled by the parent class with The change does nothing more than iterating over all Keyword arguments which where previously just ignored. |
@Pierre-Sassoulas I just opened pylint-dev/pylint#4207 to address the remaining pylint issue. The local tests pass. For CI you would need to merge this MR and release a new astroid version first. I would suggest |
I'll let @hippo91 review before merging. I don't see a problem with the changes but I'm not very relevant for astroid's MR. We can't release |
I don't know if there is a solution for pylint-dev/pylint#4206 besides excluding the test. As far as I know this isn't a definite blocker, is it? As for this MR, the fix is a definite improvement. I have been testing it with https://github.com/home-assistant/core which as a fairly large codebase and only noticed the error I fixed in pylint-dev/pylint#4207. It would remove around 90 |
@Pierre-Sassoulas Would that work for you? I know a new release of pylint and astroid would be a huge help, especially because of the fixed old issues pylint-dev/pylint#3167 and now pylint-dev/pylint#3202. |
Hmm, no I think it's a blocker, it means a crash is happening when we analyses |
I released 2.7.2 with this problem because I forgot to launch the acceptance test when releasing. |
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.
@cdce8p thanks for this PR. I definitely think it is ok and an improvement!
@hippo91 Would you mind creating a new bugfix release of astroid, |
I would assume that a fix for pylint-dev/pylint#4206 if there is any, would take at least a while longer. |
Description
This MR adds
Keywords
as a field to iterate over when getting the children of aClassDef
.@hippo91 Would you mind taking a look at this? I'm a bit unsure how to best test this or if at all. In the end, it will be checked by pylint. The tests are passing with the current master.
Type of Changes
Related Issue
Closes pylint-dev/pylint#3202