Commit graph

258 commits

Author SHA1 Message Date
Miss Islington (bot)
b01caf1d9d
[3.12] gh-113255: Clarify docs for typing.reveal_type (GH-113286) (#113323)
gh-113255: Clarify docs for `typing.reveal_type` (GH-113286)
(cherry picked from commit 11ee912327)

Co-authored-by: Kir <note351@hotmail.com>
Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
2023-12-20 17:36:45 +00:00
Alex Waygood
9aa5ff82d4
[3.12] gh-111681: minor fixes to typing doctests; remove unused imports in test_typing (#111682) (#112035)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-11-13 14:08:57 +00:00
Miss Islington (bot)
42699c82d7
[3.12] Glossary: Add "static type checker" (GH-111837) (#111854)
Glossary: Add "static type checker" (GH-111837)
(cherry picked from commit 8ab7ad6308)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-11-08 14:45:17 +00:00
Miss Islington (bot)
35141842d3
[3.12] gh-111729: update generic syntax for typing.Concatenate sample code in Doc/library/typing.rst (GH-111734) (#111814)
(cherry picked from commit c3e19c3a62)

Co-authored-by: 方糖 <cubesugarcheese@qq.com>
2023-11-07 01:00:16 +00:00
Miss Islington (bot)
edff7c1614
[3.12] gh-111151: Convert monospaced directives to :ref: (GH-111152) (#111269)
gh-111151: Convert monospaced directives to :ref: (GH-111152)
(cherry picked from commit 1198076447)

Co-authored-by: InSync <122007197+InSyncWithFoo@users.noreply.github.com>
2023-10-24 15:30:21 +00:00
Miss Islington (bot)
ee2f2bdb30
[3.12] Enhance TypedDict docs around required/optional keys (GH-109547) (#109982)
Enhance TypedDict docs around required/optional keys (GH-109547)

As discussed in comments to GH-109544, the semantics of this attribute
are somewhat confusing. Add a note explaining its limitations and
steering users towards __required_keys__ and __optional_keys__ instead.
(cherry picked from commit f49958c886)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-10-04 13:56:58 +02:00
Alex Waygood
25bf0564c4
[3.12] Fix typos in docs and comments (#109619) (#109621)
Fix typos in docs and comments (#109619)

Co-authored-by: Heinz-Alexander Fuetterer <35225576+afuetterer@users.noreply.github.com>
2023-10-02 17:34:49 +00:00
Miss Islington (bot)
5531d03d99
[3.12] Fix typo in typing docs: Remove redundant backtick (GH-108559) (#108560)
Fix typo in typing docs: Remove redundant backtick (GH-108559)
(cherry picked from commit 72b615ab01)

Co-authored-by: nikkie <takuyafjp+develop@gmail.com>
2023-08-29 00:24:41 +02:00
Miss Islington (bot)
f7e16d74ad
[3.12] Clarify Self interaction with subclasses (GH-107511) (#107548)
Clarify `Self` interaction with subclasses (GH-107511)
(cherry picked from commit c8872f4285)

Co-authored-by: Alexandru Mărășteanu <alexei@users.noreply.github.com>
2023-08-02 01:52:28 +02:00
Miss Islington (bot)
9f58d9ec90
[3.12] gh-105578: Add more usage examples to typing.AnyStr docs (GH-107045) (#107503)
gh-105578: Add more usage examples to `typing.AnyStr` docs (GH-107045)

``typing.AnyStr`` has different semantics to ``str | bytes``, which often leads to user confusion
(cherry picked from commit f877b32b87)

Co-authored-by: Michael The <michael-the1@users.noreply.github.com>
2023-07-31 15:33:00 +00:00
Miss Islington (bot)
2c0a99d322
[3.12] gh-107422: Remove outdated TypedDict example from typing docs (GH-107436) (#107437)
gh-107422: Remove outdated `TypedDict` example from typing docs (GH-107436)
(cherry picked from commit 89fd4f4a3f)

Co-authored-by: Rakesh Sabale <102187286+ghubrakesh@users.noreply.github.com>
2023-07-29 17:12:50 +00:00
Alex Waygood
e99b69c5ae
[3.12] gh-106745: typing docs: Clarify that removal of PEP-585 aliases is not currently planned (#106748) (#106772) 2023-07-15 11:31:12 +01:00
Miss Islington (bot)
128a962482
[3.12] gh-106461: typing: Consolidate docs on Callable (GH-106462) (#106574)
gh-106461: typing: Consolidate docs on `Callable` (GH-106462)
(cherry picked from commit ca8b55c7f5)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-07-09 22:21:54 +01:00
Miss Islington (bot)
84189640b7
[3.12] Improve typing docs on the type of class objects (GH-106081) (#106096)
Improve typing docs on the type of class objects (GH-106081)
(cherry picked from commit 3eeb8c8906)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-26 09:43:24 +01:00
Miss Islington (bot)
de1c090879
[3.12] Typing docs: fix typo in annotating tuples comment (GH-106048) (#106049)
Typing docs: fix typo in annotating tuples comment (GH-106048)
(cherry picked from commit 8ef0ee4ebc)

Co-authored-by: Eamon Tracey <66919574+EamonTracey@users.noreply.github.com>
2023-06-23 21:35:00 +01:00
Miss Islington (bot)
1ffcd49be2
[3.12] Typing docs: improve the guidance on annotating tuples (GH-106021) (#106027)
Typing docs: improve the guidance on annotating tuples (GH-106021)
(cherry picked from commit 968435ddb1)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-23 15:48:29 +01:00
Miss Islington (bot)
5e524ef346
[3.12] typing docs: Improve the intro to each section (GH-105901) (#105902)
typing docs: Improve the intro to each section (GH-105901)
(cherry picked from commit 4426279a43)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-19 01:02:48 +01:00
Miss Islington (bot)
9012c55af8
[3.12] More reorganisation of the typing docs (GH-105787) (#105810)
More reorganisation of the typing docs (GH-105787)
(cherry picked from commit da911a6b22)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-15 07:12:42 +01:00
Miss Islington (bot)
1573f1605f
[3.12] Improve docs for typing.dataclass_transform (GH-105792) (#105809)
Improve docs for `typing.dataclass_transform` (GH-105792)
(cherry picked from commit 006a453205)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-15 07:12:26 +01:00
Alex Waygood
52a2bbdc9d
[3.12] Typing docs: move the deprecated stuff below the non-deprecated stuff (#105781) (#105783) 2023-06-14 16:03:30 +01:00
Miss Islington (bot)
7c298d2dc5
[3.12] Miscellaneous improvements to the typing docs (GH-105529) (#105567)
Miscellaneous improvements to the typing docs (GH-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.
(cherry picked from commit 8e755923c9)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-09 15:37:33 +00:00
Miss Islington (bot)
3c5f0eadd8
[3.12] Further improve docs for typing.Annotated (GH-105498) (#105503)
Further improve docs for `typing.Annotated` (GH-105498)
(cherry picked from commit d213c2990f)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-08 15:12:35 +00:00
Miss Islington (bot)
9a7c4a5f39
[3.12] typing: Improve documentation of generic classes and aliases (GH-105369) (#105453)
typing: Improve documentation of generic classes and aliases (GH-105369)
(cherry picked from commit d63a7c3694)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-07 15:04:14 +00:00
Miss Islington (bot)
241c36e1dc
[3.12] gh-97797: Improve documentation for typing.Annotated (GH-105365) (#105448)
gh-97797: Improve documentation for typing.Annotated (GH-105365)
(cherry picked from commit e26d296984)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-07 14:57:25 +01:00
Miss Islington (bot)
92ab560ef5
[3.12] Improve docs for typing.TypeAlias (GH-105372) (#105446)
Improve docs for `typing.TypeAlias` (GH-105372)
(cherry picked from commit c5ec51ec8f)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-07 14:45:54 +01:00
Miss Islington (bot)
2cfe778d7f
[3.12] Improve code examples in typing.rst (GH-105346) (#105422)
Improve code examples in `typing.rst` (GH-105346)
(cherry picked from commit 81c81328a4)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-07 08:00:22 +01:00
Miss Islington (bot)
a36fb691ac
[3.12] typing docs: Make the PEPs list an expandable section, hidden by default (GH-105353) (#105420)
typing docs: Make the PEPs list an expandable section, hidden by default (GH-105353)
(cherry picked from commit d7645124f5)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-06-07 07:48:44 +01:00
Miss Islington (bot)
f4969eb315
[3.12] typing.NewType docs: the future performance improvements are now in the past (GH-105354) (#105414)
`typing.NewType` docs: the future performance improvements are now in the past (GH-105354)
(cherry picked from commit 5f65ff0370)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-06 20:55:37 -07:00
Miss Islington (bot)
dcee0aa911
[3.12] gh-103921: Document PEP 695 (GH-104642) (#104989)
(cherry picked from commit 060277d96b)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-26 18:19:34 +00:00
Miss Islington (bot)
a064233886
[3.12] gh-104874: Document NewType.__supertype__ (GH-104875) (#104906)
gh-104874: Document NewType.__supertype__ (GH-104875)
(cherry picked from commit 41768a2bd3)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-25 00:33:52 +01: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