Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.3k
New semantic analyzer: Fix (de)serialization of broken named tuples#6421
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fdc5fb7
Fix (de)serialization of broken named tuples
ilevkivskyi 2f986f9
Clean-up a bit the logic and add a test
ilevkivskyi 4fcf6bd
Fix docstring
ilevkivskyi 1053b0f
Fix self-check
ilevkivskyi bf3809e
Address CR (docstrings and comments)
ilevkivskyi f600f7c
Fix typo
ilevkivskyi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -3955,6 +3955,28 @@ def add_symbol(self, name: str, node: SymbolNode, context: Optional[Context], | ||
| module_hidden=module_hidden) | ||
| return self.add_symbol_table_node(name, symbol, context) | ||
| def add_symbol_skip_local(self, name: str, node: SymbolNode) -> None: | ||
| """Same as above, but skipping the local namespace. | ||
| This doesn't check for previous definition and is only used | ||
| for serialization of method-level classes. | ||
ilevkivskyi marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| Classes defined within methods can be exposed through an | ||
| attribute type, but method-level symbol tables aren't serialized. | ||
| This method can be used to add such classes to an enclosing, | ||
| serialized symbol table. | ||
| """ | ||
| # TODO: currently this is only used by named tuples. Use this method | ||
| # also by typed dicts and normal classes, see issue #6422. | ||
| if self.type is not None: | ||
| names = self.type.names | ||
| kind = MDEF | ||
| else: | ||
| names = self.globals | ||
| kind = GDEF | ||
| symbol = SymbolTableNode(kind, node) | ||
| names[name] = symbol | ||
| def current_symbol_table(self) -> SymbolTable: | ||
| if self.is_func_scope(): | ||
| assert self.locals[-1] is not None | ||
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
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
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
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.
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.
What's this change? Is is related to the rest of this PR?
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 is needed because otherwise incremental tests crash with the new analyzer (I added couple incremental tests) with something like
'BuildManager' doesn't have attribute 'semantic_analyzer'.