-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Refactor: Move code out of semantic analyzer pass 2 #4855
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.
Looks good! I think we should merge this soon to avoid conflicts, so I am going to do this now.
@@ -277,6 +273,10 @@ def visit_file(self, file_node: MypyFile, fnam: str, options: Options, | |||
self.is_typeshed_stub_file = self.errors.is_typeshed_file(file_node.path) | |||
self.globals = file_node.names | |||
self.patches = patches | |||
self.named_tuple_analyzer = NamedTupleAnalyzer(options, self) |
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.
There is a bit strange asymmetry between NamedTupleAnanlyzer
and TypedDictAnalyzer
, because only the latter needs self.msg
. It is needed by check_for_explicit_any
, and it is a bit surprising that it doesn't appear in NamedTupleAnalyzer
. I think it would be good or explain this asymmetry.
@@ -1794,11 +1603,11 @@ def visit_assignment_stmt(self, s: AssignmentStmt) -> None: | |||
for lvalue in s.lvalues: | |||
self.store_declared_types(lvalue, s.type) | |||
self.check_and_set_up_type_alias(s) | |||
self.process_newtype_declaration(s) | |||
self.newtype_analyzer.process_newtype_declaration(s) |
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.
Rather a comment for myself: NewType
and TypeVar
not requiring self.is_func_scope()
are by interesting coincidence(?) behave in weird way with forward references in fine grained, see e.g. #4615
This moves the semantic analysis of named tuples, TypedDicts, call-based
Enum and NewType to separate modules. I chose these based on these
criteria:
valuable.
There are still other bits we could move away in the future.
Also extended the abstract semantic analyzer API to support these
features.