Refactor: Move code out of semantic analyzer pass 2#4855
Merged
ilevkivskyi merged 6 commits intomasterfrom Apr 4, 2018
Merged
Conversation
ilevkivskyi
approved these changes
Apr 4, 2018
Member
ilevkivskyi
left a comment
There was a problem hiding this comment.
Looks good! I think we should merge this soon to avoid conflicts, so I am going to do this now.
| 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) |
Member
There was a problem hiding this comment.
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.
| 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) |
Member
There was a problem hiding this comment.
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 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 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.