Alex Waygood
da911a6b22
More reorganisation of the typing docs ( #105787 )
2023-06-15 06:52:18 +01:00
Alex Waygood
006a453205
Improve docs for `typing.dataclass_transform` ( #105792 )
2023-06-15 06:51:42 +01:00
Alex Waygood
7b1f0f204a
gh-105570: Deprecate unusual ways of creating empty TypedDicts ( #105780 )
...
Deprecate two methods of creating typing.TypedDict classes with 0 fields using the functional syntax: `TD = TypedDict("TD")` and `TD = TypedDict("TD", None)`. Both will be disallowed in Python 3.15. To create a TypedDict class with 0 fields, either use `class TD(TypedDict): pass` or `TD = TypedDict("TD", {})`.
2023-06-14 14:58:41 +00:00
Alex Waygood
4a113e24a3
Typing docs: move the deprecated stuff below the non-deprecated stuff ( #105781 )
2023-06-14 15:19:27 +01:00
Alex Waygood
ad56340b66
gh-105566: Deprecate unusual ways of creating `typing.NamedTuple` classes ( #105609 )
...
Deprecate creating a typing.NamedTuple class using keyword arguments to denote the fields (`NT = NamedTuple("NT", x=int, y=str)`). This will be disallowed in Python 3.15. Use the class-based syntax or the functional syntax instead.
Two methods of creating `NamedTuple` classes with 0 fields using the functional syntax are also deprecated, and will be disallowed in Python 3.15: `NT = NamedTuple("NT")` and `NT = NamedTuple("NT", None)`. To create a `NamedTuple` class with 0 fields, either use `class NT(NamedTuple): pass` or `NT = NamedTuple("NT", [])`.
2023-06-14 13:38:49 +01:00
Jelle Zijlstra
fc8037d84c
gh-104873: Add typing.get_protocol_members and typing.is_protocol ( #104878 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-14 05:35:06 -07:00
Alex Waygood
8e755923c9
Miscellaneous improvements to the typing docs ( #105529 )
...
Mostly, these are changes so that we use shorter sentences and shorter paragraphs. In particular, I've tried to make the first sentence introducing each object in the typing API short and declarative.
2023-06-09 15:08:57 +00:00
Alex Waygood
d213c2990f
Further improve docs for `typing.Annotated` ( #105498 )
2023-06-08 14:36:30 +00:00
Alex Waygood
d63a7c3694
typing: Improve documentation of generic classes and aliases ( #105369 )
2023-06-07 14:02:40 +00:00
Alex Waygood
e26d296984
gh-97797: Improve documentation for typing.Annotated ( #105365 )
2023-06-07 06:35:34 -07:00
Alex Waygood
c5ec51ec8f
Improve docs for `typing.TypeAlias` ( #105372 )
2023-06-07 06:31:02 -07:00
Alex Waygood
81c81328a4
Improve code examples in `typing.rst` ( #105346 )
2023-06-07 07:47:11 +01:00
Alex Waygood
d7645124f5
typing docs: Make the PEPs list an expandable section, hidden by default ( #105353 )
...
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-06-07 07:37:02 +01:00
Alex Waygood
5f65ff0370
`typing.NewType` docs: the future performance improvements are now in the past ( #105354 )
2023-06-06 17:18:09 -07:00
Jelle Zijlstra
060277d96b
gh-103921: Document PEP 695 ( #104642 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-26 10:48:17 -07:00
Tomas R
fea8632ec6
gh-104786: Remove kwargs-based TypedDict creation ( #104891 )
...
Deprecated since Python 3.11.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-25 21:14:58 +01:00
Jelle Zijlstra
41768a2bd3
gh-104874: Document NewType.__supertype__ ( #104875 )
2023-05-25 00:23:28 +01:00
Sebastian Rittau
abdda5b133
gh-92871: Remove typing.{io,re} namespaces ( #92873 )
...
Closes #92871
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-23 13:44:26 +00:00
Jelle Zijlstra
ab71acd67b
typing docs: Move some classes out of the "Generics" section ( #104707 )
...
- AnyStr can be used in type annotations, contrary to the section header
- Unpack can also be used in annotations, and its use is not restricted
to generics. It makes more sense with other building blocks like Required.
- Protocol is not necessarily generic.
Also fix the indentation for two notes associated with Concatenate.
Split off from #104642 , but I think this change is independently an
improvement.
2023-05-21 06:00:50 -07:00
Jelle Zijlstra
2f7b5e458e
Minor improvements to typing docs ( #104465 )
2023-05-14 12:53:15 +01:00
chgnrdv
a7a2dbbf72
gh-104010: Separate and improve docs for `typing.get_origin` and `typing.get_args` ( #104013 )
...
* separate documentation and examples for both functions
* add examples demonstrating behaviour with unsupported types
* document return value of `get_origin` for `ParamSpecArgs` and `ParamSpecKwargs` instances
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-10 07:48:55 -07:00
Shantanu
1f5679540c
gh-102500: Remove mention of bytes shorthand ( #104281 )
...
The bytes shorthand was removed in PEP 688:
https://peps.python.org/pep-0688/#no-special-meaning-for-bytes
I also remove the reference to `collections.abc.ByteString`, since that
object is deprecated (#91896 ) and has different semantics (#102092 )
2023-05-08 14:40:51 +01:00
Shantanu
09b7695f12
gh-91896: Deprecate collections.abc.ByteString ( #102096 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-05-04 09:39:33 -07:00
Shantanu
82ba6ce303
Improve assert_type phrasing ( #104081 )
...
I'd like to make the fact that this does nothing at runtime
really obvious, since I suspect this is unintuitive for users who are
unfamiliar with static type checking.
I thought of this because of
https://discuss.python.org/t/add-arg-check-type-to-types/26384
wherein I'm skeptical that the user really did want `assert_type`.
2023-05-01 23:05:25 -07:00
Franek Magiera
dc3f97549a
gh-103629: Update typing.Unpack docs in compliance with PEP 692 ( #103894 )
2023-04-26 16:39:39 -06:00
James Hilton-Balfe
ecad802e3f
Fix old behaviour in typing documentation ( #103400 )
2023-04-09 22:55:32 +01:00
Alex Waygood
644136563d
gh-74690: Document changes made to runtime-checkable protocols in 3.12 ( #103348 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-04-07 22:06:37 +01:00
Alex Waygood
6d59c9e32e
gh-102433: Use `inspect.getattr_static` in `typing._ProtocolMeta.__instancecheck__` ( #103034 )
2023-04-02 14:22:19 +01:00
Shantanu
fda95aa194
gh-103099: Link mypy docs from typing.rst ( #103100 )
2023-03-30 01:32:09 -07:00
Alex Waygood
58d2b30c01
gh-102936: typing: document performance pitfalls of protocols decorated with `@runtime_checkable` ( #102937 )
2023-03-23 18:18:53 +00:00
Michael K
73250000ac
Fix typos in documentation and comments (GH-102374)
...
Found some duplicate `to`s in the documentation and some code comments and fixed them.
[Misc/NEWS.d/3.12.0a1.rst](ed55c69ebd/Misc/NEWS.d/3.12.0a1.rst
) also contains two duplicate `to`s, but I wasn't sure if it's ok to touch that file. Looks auto generated. I'm happy to amend the PR if requested. :)
Automerge-Triggered-By: GH:AlexWaygood
2023-03-02 07:26:49 -08:00
Steven Troxler
0f89acf6cc
gh-101561: Add typing.override decorator ( #101564 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-02-27 13:16:11 -08:00
Nikita Sobolev
a498de4c0e
gh-101100: Fix sphinx warnings in `typing` module docs ( #102260 )
2023-02-25 21:48:00 +00:00
Furkan Onder
3690688149
GH-101898: Fix missing term references for hashable definition ( #101899 )
...
Fix missing term references for hashable definition
2023-02-14 14:20:11 +04:00
FrozenBob
deaf090699
gh-100673: Removed erroneous note in the get_type_hints docs ( #100701 )
...
Removed erroneous note in the get_type_hints docs
typing.get_type_hints still includes base class type hints.
2023-01-07 17:31:47 +00:00
MonadChains
f5b7b19bf1
gh-99535: Add test for inheritance of annotations and update documentation ( #99990 )
2022-12-24 12:07:14 -08:00
Erik De Bonte
5c19050546
gh-99957: Add `frozen_default` parameter on `dataclass_transform` ( #99958 )
2022-12-05 19:35:43 -08:00
GabrielAnguita
1bf983ce7e
gh-99662: fix typo in typing.TypeVarTuple docs ( #99672 )
2022-11-21 20:02:55 -08:00
Sebastian Rittau
65d1407737
gh-92871: Postpone the removal of typing.{io,re} to 3.13 ( #98958 )
2022-11-01 20:51:45 -07:00
Eclips4
be0cf82ae4
gh-98602: [typing docs] Use quotes for forward reference in TypeVarTuple example ( #98605 )
2022-10-25 16:32:52 +01:00
Nikita Sobolev
5076108872
gh-98623: Fix base classes in `typing.rst` ( #98626 )
2022-10-25 07:06:13 -07:00
Nikita Sobolev
e3b9dd8e87
gh-98507: [typing docs] Rephrase "now supports `[]`" to "now supports subscripting" ( #98508 )
2022-10-24 19:10:25 +01:00
Nikita Sobolev
1a217f9ffc
gh-98500: Fix typing docs for `*View` classes ( #98511 )
2022-10-24 10:47:32 -07:00
Omkaar
b6d5d5b60a
gh-98561: Fix a typo in typing (GH-98562)
2022-10-23 22:05:08 +08:00
Simon Legner
02389658a4
docs(typing): harmonize "See PEP x for more details" ( #97927 )
2022-10-15 12:17:51 -07:00
Shantanu
ed6344eed0
gh-96130: Rephrase use of "typecheck" verb for clarity ( #98144 )
...
I'm sympathetic to the issue report, especially in case this helps
clarify to new users that Python itself does not do type checking at runtime
2022-10-11 19:37:58 -07:00
Simon Legner
2016bc54a2
docs(typing): add "see PEP 675" to LiteralString ( #97926 )
2022-10-05 13:08:07 -07:00
Shantanu
5b3a2569f4
gh-96917: link to typing.readthedocs.io from typing.rst ( #96921 )
...
See the discussion at https://github.com/python/cpython/issues/91533
2022-09-19 12:09:41 -07:00
Adrian Garcia Badaracco
07f12b5c15
gh-95337: update TypeVarTuple example ( #95338 )
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-08-30 07:57:03 -07:00
Howie Zhao
f235178bec
gh-94439: typing docs: Add minimum version to `__required_keys__` and `__optional_keys__` ( #95373 )
2022-08-12 21:23:33 -07:00