Skip to content

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

Merged
merged 9 commits into from
Jan 2, 2021

Conversation

Fidget-Spinner
Copy link
Member

@Fidget-Spinner Fidget-Spinner commented Dec 29, 2020

Please skip news, it shares the same news entry as GH-23702, thanks!

https://bugs.python.org/issue41559

@Fidget-Spinner
Copy link
Member Author

Fidget-Spinner commented Dec 29, 2020

@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.

@Fidget-Spinner
Copy link
Member Author

Fidget-Spinner commented Dec 30, 2020

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.

Copy link
Member

@gvanrossum gvanrossum left a 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.
Copy link
Member

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?

Copy link
Member Author

@Fidget-Spinner Fidget-Spinner Dec 31, 2020

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>
@Fidget-Spinner
Copy link
Member Author

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.

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.

Copy link
Member

@gvanrossum gvanrossum left a 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!

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay!

@Fidget-Spinner
Copy link
Member Author

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, test_nntplib seems to be failing for the entire cpython repo right now. I'm just going to wait it out and see if it magically fixes itself, or if the people at https://bugs.python.org/issue42794 find some other way to solve it.

@gvanrossum gvanrossum merged commit 11276cd into python:master Jan 2, 2021
@Fidget-Spinner Fidget-Spinner deleted the docs-pep612 branch January 2, 2021 09:09
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants