-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
bpo-41559: Documentation for PEP 612 #24000
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
Conversation
@gvanrossum. Sorry, I did the reverse of what I'd initially promised - I was in a writing mood :). Really no hurry to review it though, we have a long way till 3.10 beta. This felt more difficult to write than what I did for PEP 585 and PEP 604 combined! Thinking of useful examples which were also understandable by users and copy-pastable/fully working as is wasn't easy. Maybe this is a sign that the typing module needs some refactoring work by the future Docs WG people. |
Hmm I wonder if we should reorder the PEP-sized what's new items while we're at it. Strange that the current order is PEP 563, 613, 604, 612. |
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 so much for this very thorough doc update! I have just a few nits.
Next, do you want to help fixing the support for this in mypy? There's some code, but it's not working right.
.. note:: | ||
A ``GenericAlias`` object with :class:`typing.ParamSpec` parameters may not | ||
have correct ``__parameters__`` after substitution because | ||
:class:`typing.ParamSpec` is intended primarily for static type checking. |
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.
You don't need to add this to the note, but privately I'm interested in an example where it goes wrong?
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 example is from the typing module, though it will behave the same with the builtin GenericAlias'''
from typing import ParamSpec, TypeVar, Generic
P = ParamSpec('P')
T = TypeVar('T')
class X(Generic[P]): ...
# Empty tuple, because T is nested inside that list
print(X[int, str, T].__parameters__)
Co-Authored-By: Guido van Rossum <gvanrossum@users.noreply.github.com>
You're welcome! Unfortunately I have no clue how mypy works internally, so I don't think I'm the right person for that right now. |
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.
Everything else is fine now!
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.
Okay!
Thank you for taking the time to review this prosaic chunk of text. Getting this approved is an awesome way to start the new year! BTW, |
Please skip news, it shares the same news entry as GH-23702, thanks!
https://bugs.python.org/issue41559