Skip to content
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

gh-105286: Improve typing.py docstrings #105287

Merged
merged 12 commits into from
Jun 5, 2023
Prev Previous commit
Next Next commit
Make module docstring more user-facing
  • Loading branch information
AlexWaygood committed Jun 5, 2023
commit f9e27e23d0f5169d11354501086d8b80491ee89b
21 changes: 10 additions & 11 deletions Lib/typing.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
"""
The typing module: Support for gradual typing as defined by PEP 484 and subsequent PEPs.
Copy link
Member Author

Choose a reason for hiding this comment

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

Many other PEPs have revised the typing spec since PEP 484


At large scale, the structure of the module is following:
* Imports and exports, all public names should be explicitly added to __all__.
* Internal helper functions: these should never be used in code outside this module.
* _SpecialForm and its instances (special forms):
Any name not present in __all__ is an implementation detail
that may be changed without notice. Use at your own risk!

Among other things, the module includes the following:
* Generic, Protocol, and internal machinery to support generic aliases.
All subscripted types like X[int], Union[int, str] are generic aliases.
* Various "special forms" that have unique meanings in type annotations:
NoReturn, Never, ClassVar, Self, Concatenate, Unpack, and others.
* Classes whose instances can be type arguments:
* Classes whose instances can be type arguments to generic classes and functions:
TypeVar, ParamSpec, TypeVarTuple.
* The core of internal generics API: _GenericAlias and _VariadicGenericAlias, the latter is
currently only used by Tuple and Callable. All subscripted types like X[int], Union[int, str],
etc., are instances of either of these classes.
* The public counterpart of the generics API consists of two classes: Generic and Protocol.
* Public helper functions: get_type_hints, overload, cast, final, and others.
Copy link
Member Author

Choose a reason for hiding this comment

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

Many other public helper functions have been added that aren't listed here, so I just made it an abbreviated list and put "and others" at the end

* Deprecated aliases for collections.abc ABCs.
* Several additional protocols:
* Several protocols to support duck-typing:
SupportsFloat, SupportsIndex, SupportsAbs, and others.
* Special types: NewType, NamedTuple, TypedDict.
* Deprecated aliases for builtin types and collections.abc ABCs.
"""

from abc import abstractmethod, ABCMeta
Expand Down