Skip to content

Conversation

@AlexWaygood
Copy link
Member

Currently some of the typing-module stdlib aliases have docstrings that reflect their deprecation, but others inherit a generic docstring that does not mention any deprecation (and implies that they add something over and above the stdlib class that they're aliasing):

>>> from typing import *
>>> help(Tuple)
Help on _TupleType in module typing:

Tuple = typing.Tuple
    Deprecated alias to builtins.tuple.

    Tuple[X, Y] is the cross-product type of X and Y.

    Example: Tuple[T1, T2] is a tuple of two elements corresponding
    to type variables T1 and T2.  Tuple[int, float, str] is a tuple
    of an int, a float and a string.

    To specify a variable-length tuple of homogeneous type, use Tuple[T, ...].

>>> help(Hashable)
Help on _SpecialGenericAlias in module typing:

Hashable = typing.Hashable
    A generic version of collections.abc.Hashable.

This PR improves the generic fallback docstring so that it's consistent with the "manual" docstrings we give for the aliases like Tuple and Callable:

>>> from typing import *
>>> help(Tuple)
Help on _TupleType in module typing:

Tuple = typing.Tuple
    Deprecated alias to builtins.tuple.

    Tuple[X, Y] is the cross-product type of X and Y.

    Example: Tuple[T1, T2] is a tuple of two elements corresponding
    to type variables T1 and T2.  Tuple[int, float, str] is a tuple
    of an int, a float and a string.

    To specify a variable-length tuple of homogeneous type, use Tuple[T, ...].

>>> help(Hashable)
Help on _SpecialGenericAlias in module typing:

Hashable = typing.Hashable
    Deprecated alias to collections.abc.Hashable.

@AlexWaygood AlexWaygood requested a review from carljm December 30, 2025 14:03
@AlexWaygood AlexWaygood merged commit 18f3c59 into python:main Jan 2, 2026
56 checks passed
@AlexWaygood AlexWaygood deleted the deprecated-alias-docs branch January 2, 2026 11:31
@miss-islington-app
Copy link

Thanks @AlexWaygood for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 2, 2026
…ct their deprecation (pythonGH-143295)

(cherry picked from commit 18f3c59e57e5d30218210136060310310b10ff72)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Jan 2, 2026

GH-143348 is a backport of this pull request to the 3.14 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 2, 2026
…ct their deprecation (pythonGH-143295)

(cherry picked from commit 18f3c59)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Jan 2, 2026
@bedevere-app
Copy link

bedevere-app bot commented Jan 2, 2026

GH-143349 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jan 2, 2026
AlexWaygood added a commit that referenced this pull request Jan 2, 2026
…o reflect their deprecation (GH-143295) (#143349)

Update docstrings of `typing.Hashable`, `typing.List`, etc., to reflect their deprecation (GH-143295)
(cherry picked from commit 18f3c59)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood added a commit that referenced this pull request Jan 2, 2026
…o reflect their deprecation (GH-143295) (#143348)

Update docstrings of `typing.Hashable`, `typing.List`, etc., to reflect their deprecation (GH-143295)
(cherry picked from commit 18f3c59)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
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.

1 participant