-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Use lookup_fully_qualified for SemanticAnalyzer.named_type #11332
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.
This looks great! The old behavior was clearly inconsistent.
It looks like this will be a breaking change to some plugins? If that's the case, we'll need to add a comment to #6617 about the change, and explain what needs to be done to support the new behavior.
mypy/semanal.py
Outdated
|
||
def str_type(self) -> Instance: | ||
return self.named_type('__builtins__.str') | ||
return self.named_type('builtins.str') | ||
|
||
def named_type(self, qualified_name: str, args: Optional[List[Type]] = None) -> Instance: |
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.
Rename qualified_name
to fullname
?
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.
It looks like this will be a breaking change to some plugins?
Yes. I think we should notify that we are using full name now and we support direct call on builtins
module instead of __builtins__
.
Can we close #6578 now? |
Due to python/mypy#11332, mypy would crash because `__builtins__` is not part of `ctx.api` modules, `builtins` is
* build(deps): bump mypy from 0.920 to 0.930 * fix: avoid mypy plugin crash Due to python/mypy#11332, mypy would crash because `__builtins__` is not part of `ctx.api` modules, `builtins` is * fix tests
) Related to python#6578 This PR replaces lookup_qualified with lookup_fully_qualified for SemanticAnalyzer.named_type. Now it's consistant with the implementation of checker.named_type. This change also allows calling named_type without dunders.
Related to python#6578. builtin_type could be totally replaced with named_type after python#11332. Also renames other builtin_type for consistency since all of them are actually calling named_type.
* build(deps): bump mypy from 0.920 to 0.930 * fix: avoid mypy plugin crash Due to python/mypy#11332, mypy would crash because `__builtins__` is not part of `ctx.api` modules, `builtins` is * fix tests
Description
Related #6578
This PR replaces
lookup_qualified
withlookup_fully_qualified
forSemanticAnalyzer.named_type
. Now it's consistant with the implementation of checker.named_type. This change also allows calling named_type without dunders.Test Plan
Shouldn't affect any tests.