Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a6fe738
bpo-45680: Clarify documentation on ``GenericAlias`` objects
AlexWaygood Oct 30, 2021
cef0930
Correct typo
AlexWaygood Oct 30, 2021
614fce5
Add more `shelve` classes
AlexWaygood Oct 31, 2021
74269b8
Remove brackets
AlexWaygood Nov 1, 2021
671579b
Add link to container classes, remove use of the word 'they'
AlexWaygood Nov 1, 2021
d367338
Improve cross-references to data model docs
AlexWaygood Nov 2, 2021
d945e06
Move example to ``__class_getitem__`` docs in the data model
AlexWaygood Nov 2, 2021
629a29d
revert line 4813
AlexWaygood Nov 2, 2021
5dd309c
More instances where it is implied that only containers can be parame…
AlexWaygood Nov 2, 2021
5dbccad
Improve references in glossary and typing docs
AlexWaygood Nov 2, 2021
bc457dd
Fix typing docs link to ``__class_getitem__`` method
AlexWaygood Nov 2, 2021
d398971
Add note about ``typing.Generic``
AlexWaygood Nov 2, 2021
a195216
Merge branch 'generic-alias-docs' of https://github.com/AlexWaygood/c…
AlexWaygood Nov 2, 2021
af257a6
Update glossary
AlexWaygood Nov 18, 2021
eb7e7be
Update typing
AlexWaygood Nov 18, 2021
5c8fe0d
update datamodel
AlexWaygood Nov 18, 2021
010ca86
delete news
AlexWaygood Nov 18, 2021
682cd6d
Merge remote-tracking branch 'origin/main' into generic-alias-docs
AlexWaygood Nov 18, 2021
92e0463
A few tweaks
AlexWaygood Nov 19, 2021
dd3369e
Add full stop.
AlexWaygood Nov 19, 2021
6e2d8f5
Remove redundant clause.
AlexWaygood Nov 19, 2021
43f9429
Update Doc/library/stdtypes.rst
AlexWaygood Nov 19, 2021
ba2af17
Reduce diff
AlexWaygood Nov 29, 2021
2776b8d
Trailing whitespace
AlexWaygood Nov 29, 2021
f2efd8b
Update Doc/library/stdtypes.rst
AlexWaygood Dec 4, 2021
ec8a509
Fix CI
AlexWaygood Dec 4, 2021
8fad702
Improve markup readability
AlexWaygood Dec 5, 2021
e5a57e8
Steer clear of the word "subtype"
AlexWaygood Dec 5, 2021
ae21ffe
Tweak
AlexWaygood Dec 5, 2021
3944e8c
Apply formatting suggestions from code review
Fidget-Spinner Jan 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Apply formatting suggestions from code review
  • Loading branch information
Fidget-Spinner authored Jan 19, 2022
commit 3944e8caf8034da4828e9d49bfc2836477cf9d8c
15 changes: 8 additions & 7 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4854,11 +4854,12 @@ type and the :class:`bytes` data type:
:ref:`re.Match <match-objects>` object where the return values of
``x.group(0)`` and ``x[0]`` will both be of type :class:`str`. We can
Comment thread
Fidget-Spinner marked this conversation as resolved.
represent this kind of object in type annotations with the ``GenericAlias``
``re.Match[str]``
``re.Match[str]``.

* If ``y = re.search(b'bar', b'bar')``, (note the ``b`` for :class:`bytes`), ``y`` will also be an instance
of ``re.Match``, but the return values of ``y.group(0)`` and ``y[0]`` will
both be of type :class:`bytes`. In type annotations, we would represent this
* If ``y = re.search(b'bar', b'bar')``, (note the ``b`` for :class:`bytes`),
``y`` will also be an instance of ``re.Match``, but the return
values of ``y.group(0)`` and ``y[0]`` will both be of type
:class:`bytes`. In type annotations, we would represent this
variety of :ref:`re.Match <match-objects>` objects with ``re.Match[bytes]``.

``GenericAlias`` objects are instances of the class
Expand Down Expand Up @@ -4920,8 +4921,8 @@ Calling :func:`repr` or :func:`str` on a generic shows the parameterized type::
>>> str(list[int])
'list[int]'

The :meth:`~object.__getitem__` method of generic containers will raise an exception to disallow
mistakes like ``dict[str][str]``::
The :meth:`~object.__getitem__` method of generic containers will raise an
exception to disallow mistakes like ``dict[str][str]``::

>>> dict[str][str]
Traceback (most recent call last):
Expand Down Expand Up @@ -5048,7 +5049,7 @@ All parameterized generics implement special read-only attributes.
.. seealso::

:pep:`484` - Type Hints
Introducing Python's framework for type annotations
Introducing Python's framework for type annotations.

:pep:`585` - "Type Hinting Generics In Standard Collections"
Comment thread
Fidget-Spinner marked this conversation as resolved.
Introducing the ability to natively parameterize standard-library
Expand Down