stubgen: fixes and simplifications#15232
Merged
JelleZijlstra merged 2 commits intopython:masterfrom May 18, 2023
Merged
Conversation
Member
|
There's a CI failure (apparently only when mypyc is enabled). |
Collaborator
Author
|
This turned out to be a python 3.11 failure because |
hauntsaninja
approved these changes
May 15, 2023
Collaborator
hauntsaninja
left a comment
There was a problem hiding this comment.
Thanks, this cleans up several things. I'll leave open for a couple days in case someone wants to take a second look (many lines touched, so it's easy to miss things in review).
hamdanal
added a commit
to hamdanal/mypy
that referenced
this pull request
Oct 21, 2023
The semantic analyzer treats properties as overloaded functions. This was previously ignored by stubgen but regressed in python#15232. Fixes python#16300
JelleZijlstra
pushed a commit
that referenced
this pull request
Oct 21, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR refactors name resolution in stubgen to make it simple to use and fixes a bunch of related bugs especially when run in
--parse-onlymode. It mainly does the following:get_fullnamemethod that resolves the full name of bothNameExprandMemberExprtaking into account import aliasesprocess_decorator,process_name_expr_decorator, andprocess_member_expr_decoratorinto a single method thanks to the common name resolution usingget_fullnameIncompletefrom_typeshed) by usingself.typing_name()andself.add_typing_importwhich take into account objects of the same name defined in the fileOut of the 9 test cases added, only
testAbstractPropertyImportAliaspasses on master (added it any way because it was not tested). The other 8 all fail without this PR. The last test casetestUseTypingNamedemonstrates point4.. In existing test cases, only white space changes in four of the cases due to point5.above were made.This will allow easier additions in the future as no manual name resolution has to be made any more.