-
Notifications
You must be signed in to change notification settings - Fork 110
dev-tools replace deprecated typing aliases with those from collections
#1851
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
Merged
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
bf8180c
Partially implement changing typing to collections.abc
micpap25 f8a5b55
Merge branch 'main' into typing-update-dev-tools
mhucka 1521507
Merge branch 'main' into typing-update-dev-tools
micpap25 1edefb0
Update based on suggestions
micpap25 9ff829e
format fix
micpap25 c132c4b
Try the other way
micpap25 3194ef6
forgot a file, try this instead
micpap25 71dd583
forgot to save changes
micpap25 3ad036b
Import for type checking
micpap25 5dc77d1
format fix
micpap25 94aa361
another format fix
micpap25 9dcf16e
Merge branch 'main' into typing-update-dev-tools
micpap25 7c3ba22
Use __future__ annotations to avoid string type names
mhucka 8b2f973
Make check/mypy also check dev_tools/
mhucka 7ec3017
Go back to using typing.Set
mhucka 51175ce
chore: merge branch
mhucka 111e378
Run through check/format-incremental --apply
mhucka 8eb62f3
Revert change to check/mypy
mhucka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
This one is incorrect. The
typing.Setand the built-insetare not considered equal when used in type annotations, even if they contain the same arguments. Here is a small test program to demonstrate:In the
typingmodule, parameterizing a type with a string automatically wraps that string in aForwardRefobject. That meant thattyping.Set['BloqCountT']was identical totyping.Set[typing.ForwardRef('BloqCountT')]in the previous version of the code. However, PEP 585's built-in collections do not auto-convert strings toForwardRefobjects. When it evaluatesset['BloqCountT'], Python directly creates atypes.GenericAliascontaining the literal string'BloqCountT'.The fix in this particular case turns out to be easy: get rid of the
ForwardRefcompletely and do: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.
Good to know, because I replace
typing.Setwithsetthroughout the other parts of the code; I could go and fix that as well / remove theForwardRefusage there too? I will make the suggested fix, though.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.
Regarding this bug, it seems that making the change you recommended causes an issue in the
dev-toolsCI aboutBloqCountTbeing undefined. It seems fixing this for every typetyping.Setis changed to the built-insetwill require a lot ofTYPE_CHECKINGimports?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.
Huh. Let me look at it over the weekend.
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.
I don't have an answer to this yet, but I see all the other comments have been resolved (thank you), so what's left is this question and the .pyi files question above.
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.
Just following up to see if you've had a chance to test this? Thanks!
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.
@micpap25 Finally got back to this.
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.
In the current PR, the change does not seem to be that bad. I did it locally to test: