-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Add examples from Python 3.13: Cool New Features #587
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.
@gahjelle Looks good to me. I left a few comments/questions, but otherwise, approved!
Use PyLance in VS Code by setting Python › Analysis: Type Checking Mode or run | ||
the Pyright CLI: | ||
|
||
$ python -m pip install pyright $ pyright --pythonversion 3.13 . |
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.
Should these two commands be on separate lines?
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.
Oops, yes, definitely. It seems that the automatic comment formatter I ran is a bit eager.
python-313/typing/readonly.py
Outdated
# Only allowed to use PythonVersion instead of Version if the fields are ReadOnly | ||
print(get_version_info(py313)) |
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 find this counter-intuitive since the Version
and PythonVersion
classes specify separate types that don't belong to the same type hierarchy. They share the same structure, so they're essentially the same type by means of static duck typing, but they don't explicitly define a protocol. I guess, both are dicts with the same set of key-value pairs, so that should be enough for the type checker to treat them as equals.
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.
Right, I believe that TypedDict is all about structural typing. The PEP talks a bit about how the capabilities of ReadOnly
can be done with some complicated use of protocols instead.
I haven't quite internalized the rules for when one TypedDict can pass as the other, but everytime I sit down and think for a while, it seems to add up 🙈
python-313/typing/deprecations.py
Outdated
Use PyLance in VS Code by setting Python › Analysis: Type Checking Mode or run | ||
the Pyright CLI: | ||
|
||
$ python -m pip install pyright $ pyright --pythonversion 3.13 . |
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.
Should these two commands be on separate lines?
concatenate("three", "thirteen") | ||
add(3, 13) | ||
VersionType(3, 13) | ||
|
||
version = Version(3, 13) | ||
version.increase("patch") | ||
print(version) | ||
print(version.bugfix) |
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 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.
Thanks for the review @bzaczynski I've done a few updates to the extra typing files! |
Where to put new files:
my-awesome-article
How to merge your changes: