-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
Better handling of generic aliases #923
Conversation
a4fc868
to
43625ee
Compare
/CC: @hippo91, @Pierre-Sassoulas As discussed, this is the followup to #921. It addresses almost all test cases defined in pylint-dev/pylint#4239 with the exception that it can't detect the wrong usage of import re
re.Pattern[str] # [unsubscriptable-object]
re.Match[str] # [unsubscriptable-object]
var: re.Pattern[int] # [unsubscriptable-object] |
f109ae7
to
d22fb62
Compare
Small update: I've updated the brain for the |
If there are no objections, I would like to merge this by this weekend. After a new |
I think @hippo91 is the one that will really understand what he's reviewing :D I did not see anything wrong with the changes myself. |
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.
Well done @cdce8p . I am ok with this PR. Just left a bunch of comments. Feel free to address them or not!
and value.qname() in TYPING_ALIAS | ||
): | ||
# If typing subscript belongs to an alias | ||
# (PY37+) handle it separately. |
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.
Well done. I do not know how i can have missed that.
# This is an issue in cases where the aliased class implements it, | ||
# but the typing alias isn't subscriptable. E.g. `typing.ByteString` for PY39+ | ||
_forbid_class_getitem_access(class_def) | ||
return iter([class_def]) |
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.
I like very much this concise style! 👍
However you delete a lot of comments. It is not a pb for me if you think they where not helpful.
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.
I tend to prefer less / only the necessary comments. Most information is contained in the code already. Comments also have the habit of becoming outdated pretty quickly at which point they are more confusion than actually helpful.
@hippo91 Thanks for the quick review! |
Steps
Description
Followup to #921, see: #921 (comment)
Improve handling of typing aliases by inserting intermediate classes in mro.
Type of Changes
Related Issue
Closes: pylint-dev/pylint#4206
Closes: pylint-dev/pylint#4284