Skip to content

Fix various ParamSpec errors in typing#24176

Merged
miss-islington merged 3 commits into
python:masterfrom
Fidget-Spinner:typing-nits
Jan 11, 2021
Merged

Fix various ParamSpec errors in typing#24176
miss-islington merged 3 commits into
python:masterfrom
Fidget-Spinner:typing-nits

Conversation

@Fidget-Spinner
Copy link
Copy Markdown
Member

@Fidget-Spinner Fidget-Spinner commented Jan 9, 2021

  1. ParamSpec -> TypeVar for typing.Concatenate
  2. ParamSpec's call signature should align with its documentation.
    Noticed in Fix a typo #24169

Automerge-Triggered-By: GH:gvanrossum

@Fidget-Spinner Fidget-Spinner changed the title Fix docs error in typing.Concatenate example Fix various docs errors in typing Jan 9, 2021
Comment thread Doc/library/typing.rst Outdated
see :pep:`484`.

.. class:: ParamSpec(name, *, bound=None, covariant=False, contravariant=False)
.. class:: ParamSpec(name, bound=None, covariant=False, contravariant=False)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm. I would rather add the star to the code.

Copy link
Copy Markdown
Member Author

@Fidget-Spinner Fidget-Spinner Jan 10, 2021

Choose a reason for hiding this comment

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

Hmm after giving it some thought, I agree. I realized ParamSpec and TypeVar have different init signatures, (TypeVar has *constraints and ParamSpec doesn't). And PEP 612 states that

However, enforcing these constraints would require enough additional implementation work that we judged this extension to be out of scope of this PEP. Fortunately the design of ParamSpecs are such that we can return to this idea later if there is sufficient demand.

so to prevent any backwards incompatibility in the future, we should enforce it, so that if we do add constraints in the future, existing code won't break.

Edit: bounds -> constraints

@Fidget-Spinner Fidget-Spinner changed the title Fix various docs errors in typing Fix various ParamSpec errors in typing Jan 10, 2021
@miss-islington miss-islington merged commit ace008c into python:master Jan 11, 2021
@Fidget-Spinner Fidget-Spinner deleted the typing-nits branch January 11, 2021 03:50
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
1. ParamSpec -> TypeVar for ``typing.Concatenate``
2. ParamSpec's call signature should align with its documentation.
Noticed in pythonGH-24169
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip issue skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants