Commit Graph

241 Commits

Author SHA1 Message Date
Miss Islington (bot) 8c792749cb
[3.11] Improve typing docs on the type of class objects (GH-106081) (#106097)
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:41 +01:00
Miss Islington (bot) 05d06e583b
[3.11] Typing docs: fix typo in annotating tuples comment (GH-106048) (#106050)
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:16 +01:00
Miss Islington (bot) 15f4bba7a7
[3.11] Typing docs: improve the guidance on annotating tuples (GH-106021) (#106029)
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:53:14 +01:00
Alex Waygood 8bb16f6656
[3.11] typing docs: Improve the intro to each section (#105901) (#105903)
typing docs: Improve the intro to each section (#105901)
2023-06-19 01:17:06 +01:00
Alex Waygood 6be46c37c6
[3.11] More reorganisation of the typing docs (#105787) (#105816) 2023-06-15 10:05:50 +01:00
Alex Waygood c197bd8826
[3.11] Improve docs for `typing.dataclass_transform` (#105792) (#105815)
(cherry-picked from commit 006a453205)
2023-06-15 09:56:14 +01:00
Alex Waygood ab0546881f
[3.11] Typing docs: move the deprecated stuff below the non-deprecated stuff (#105781) (#105785) 2023-06-14 15:40:02 +01:00
Alex Waygood f207b346d4
[3.11] Remove stray reference to PEP-695 in the typing docs (#105655) 2023-06-11 17:10:49 +01:00
Alex Waygood 6cb1308005
[3.11] Miscellaneous improvements to the typing docs (#105529) (#105568)
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 22:41:22 +01:00
Alex Waygood faf15fda28
[3.11] Fix two errors in the typing docs (#105559) 2023-06-09 14:14:47 +01:00
Miss Islington (bot) af80db063f
[3.11] Further improve docs for `typing.Annotated` (GH-105498) (#105504)
* 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:06:39 +00:00
Alex Waygood 02c5513b30
[3.11] [typing docs] Don't describe `Sized` and `Hashable` as deprecated in the 3.11 docs (#105496) 2023-06-08 13:09:52 +01:00
Alex Waygood ccc971714e
[3.11] typing: Improve documentation of generic classes and aliases (#105369) (#105454) 2023-06-07 21:27:15 +00:00
Jelle Zijlstra 34f23904e1
[3.11] Improve docs for `typing.TypeAlias` (GH-105372). (#105447)
(cherry picked from commit c5ec51ec8f)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-07 07:14:36 -07:00
Jelle Zijlstra d0af5272a7
[3.11] gh-97797: Improve documentation for typing.Annotated (GH-105365). (#105449)
(cherry picked from commit e26d296984)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-06-07 07:14:01 -07:00
Alex Waygood 0d2ed56f6c
[3.11] Improve code examples in `typing.rst` (#105346) (#105427) 2023-06-07 06:41:35 -07:00
Miss Islington (bot) 039f30380b
[3.11] typing docs: Make the PEPs list an expandable section, hidden by default (GH-105353) (#105421)
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:50:31 +01:00
Miss Islington (bot) 2456136360
[3.11] `typing.NewType` docs: the future performance improvements are now in the past (GH-105354) (#105415)
`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:46 -07:00
Jelle Zijlstra d34e58a1d5
[3.11] gh-103921: Improve typing documentation (GH-104642) (#105007)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-27 16:30:41 -07:00
Miss Islington (bot) 3b3f2e107b
[3.11] gh-104874: Document NewType.__supertype__ (GH-104875) (#104907)
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:35:58 +01:00
Jelle Zijlstra abb32de8c4
[3.11] typing docs: Move some classes out of the "Generics" section (GH-104707) (#104721)
- 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.

(cherry picked from commit ab71acd67b)

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-21 14:31:26 +01:00
Miss Islington (bot) f5f99756e1
[3.11] Minor improvements to typing docs (GH-104465) (#104475)
Minor improvements to typing docs (GH-104465)
(cherry picked from commit 2f7b5e458e)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-14 13:00:57 +01:00
Miss Islington (bot) a8e902d2c2
[3.11] gh-104010: Separate and improve docs for `typing.get_origin` and `typing.get_args` (GH-104013) (#104359)
* 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

(cherry picked from commit a7a2dbbf72)

Co-authored-by: chgnrdv <52372310+chgnrdv@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-10 07:49:49 -07:00
Shantanu 15624b445e
[3.11] gh-102500: collections.abc.Buffer doesn't exist in 3.11 (#104317) 2023-05-09 10:27:15 +01:00
Alex Waygood 499b79d0b9
[3.11] gh-102500: Remove mention of bytes shorthand (#104281) (#104288)
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

The reference to collections.abc.ByteString is also removed, since that object is deprecated (#91896) and has different semantics (#102092)

Although PEP 688 is new in Python 3.12, type checkers are expected to implement the new semantics for type annotations even if users are using an older version of Python, so this docs PR is backported to Python 3.11.

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2023-05-08 15:23:10 +01:00
Miss Islington (bot) 3e7e50e656
[3.11] Improve assert_type phrasing (GH-104081) (#104084)
Improve assert_type phrasing (GH-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`.
(cherry picked from commit 82ba6ce303)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2023-05-02 08:44:16 +01:00
Miss Islington (bot) 1b40618247
gh-103099: Link mypy docs from typing.rst (GH-103100)
(cherry picked from commit fda95aa194)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2023-03-30 01:39:49 -07:00
Miss Islington (bot) e2924c0ee5
gh-102936: typing: document performance pitfalls of protocols decorated with `@runtime_checkable` (GH-102937)
(cherry picked from commit 58d2b30c01)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-03-23 11:27:28 -07:00
Alex Waygood 3b1201daf6
[3.11] Fix typos in documentation and comments (GH-102374) (#102376)
[3.11] 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

Co-authored-by: Michael K <michael-k@users.noreply.github.com>
2023-03-02 16:00:06 +00:00
Miss Islington (bot) c2f42f1778
gh-101100: Fix sphinx warnings in `typing` module docs (GH-102260)
(cherry picked from commit a498de4c0e)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-02-25 13:55:49 -08:00
Miss Islington (bot) 4aeae28671
GH-101898: Fix missing term references for hashable definition (GH-101899)
Fix missing term references for hashable definition
(cherry picked from commit 3690688149)

Co-authored-by: Furkan Onder <furkanonder@protonmail.com>
2023-02-14 02:45:42 -08:00
Miss Islington (bot) a3e2407f5c
gh-100673: Removed erroneous note in the get_type_hints docs (GH-100701)
Removed erroneous note in the get_type_hints docs

typing.get_type_hints still includes base class type hints.
(cherry picked from commit deaf090699)

Co-authored-by: FrozenBob <30644137+FrozenBob@users.noreply.github.com>
2023-01-07 09:38:32 -08:00
Miss Islington (bot) 44b664e057
gh-99535: Add test for inheritance of annotations and update documentation (GH-99990)
(cherry picked from commit f5b7b19bf1)

Co-authored-by: MonadChains <monadchains@gmail.com>
2022-12-24 12:31:10 -08:00
Miss Islington (bot) 05147dc383
gh-99662: fix typo in typing.TypeVarTuple docs (GH-99672)
(cherry picked from commit 1bf983ce7e)

Co-authored-by: GabrielAnguita <60579349+GabrielAnguita@users.noreply.github.com>
2022-11-21 20:09:49 -08:00
Miss Islington (bot) b2e28c8700
gh-92871: Postpone the removal of typing.{io,re} to 3.13 (GH-98958)
(cherry picked from commit 65d1407737)

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
2022-11-01 21:00:13 -07:00
Miss Islington (bot) 4cd5ea62ac
gh-98602: [typing docs] Use quotes for forward reference in TypeVarTuple example (GH-98605)
(cherry picked from commit be0cf82ae4)

Co-authored-by: Eclips4 <80244920+Eclips4@users.noreply.github.com>
2022-10-25 08:42:12 -07:00
Miss Islington (bot) 4b68e34a6c
gh-98623: Fix base classes in `typing.rst` (GH-98626)
(cherry picked from commit 5076108872)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-10-25 07:13:16 -07:00
Miss Islington (bot) cdbfce121f
gh-98507: [typing docs] Rephrase "now supports `[]`" to "now supports subscripting" (GH-98508)
(cherry picked from commit e3b9dd8e87)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-10-24 11:16:58 -07:00
Miss Islington (bot) d9abd8a584
gh-98500: Fix typing docs for `*View` classes (GH-98511)
(cherry picked from commit 1a217f9ffc)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-10-24 10:55:11 -07:00
Miss Islington (bot) ae68a45daa
gh-98561: Fix a typo in typing (GH-98562)
(cherry picked from commit b6d5d5b60a)

Co-authored-by: Omkaar <79257339+Infiniticity@users.noreply.github.com>
2022-10-23 07:13:25 -07:00
Miss Islington (bot) d3b57dc729
docs(typing): harmonize "See PEP x for more details" (GH-97927)
(cherry picked from commit 02389658a4)

Co-authored-by: Simon Legner <Simon.Legner@gmail.com>
2022-10-15 12:25:58 -07:00
Miss Islington (bot) d22c35dfff
gh-96130: Rephrase use of "typecheck" verb for clarity (GH-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
(cherry picked from commit ed6344eed0)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2022-10-11 19:45:44 -07:00
Miss Islington (bot) 61183b95ae
docs(typing): add "see PEP 675" to LiteralString (GH-97926)
(cherry picked from commit 2016bc54a2)

Co-authored-by: Simon Legner <Simon.Legner@gmail.com>
2022-10-05 13:16:12 -07:00
Miss Islington (bot) e0d6cc8316
gh-96917: link to typing.readthedocs.io from typing.rst (GH-96921)
See the discussion at https://github.com/python/cpython/issues/91533
(cherry picked from commit 5b3a2569f4)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2022-09-19 12:19:18 -07:00
Miss Islington (bot) d00a9e0176
gh-95337: update TypeVarTuple example (GH-95338)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit 07f12b5c15)

Co-authored-by: Adrian Garcia Badaracco <1755071+adriangb@users.noreply.github.com>
2022-08-30 08:06:19 -07:00
Miss Islington (bot) 1fccb1d493
[3.11] gh-94439: typing docs: Add minimum version to `__required_keys__` and `__optional_keys__` (GH-95373) (#95944)
Co-authored-by: Howie Zhao <howiezhaohr@hotmail.com>
2022-08-13 19:42:27 +01:00
Miss Islington (bot) 7c185017a9
docs: typing.Self, fix typo (GH-94771)
* fix typo - double spelled word 'use'

* change methods names to the infinitive form
(cherry picked from commit 90a6e56e56)

Co-authored-by: Max Zhenzhera <59729293+maxzhenzhera@users.noreply.github.com>
2022-07-12 11:17:06 -07:00
Miss Islington (bot) 77bf973930
Docs: remove redundant "adverb-adjective" hyphens from compound modifiers (GH-94551) (GH-94557)
Discussion: https://discuss.python.org/t/slight-grammar-fix-throughout-adverbs-dont-need-hyphen/17021
(cherry picked from commit 3440d197a5)

Co-authored-by: Ned Batchelder <ned@nedbatchelder.com>
2022-07-05 14:30:19 +02:00
Miss Islington (bot) 64365d0df9
gh-91860: Add docs for typing.dataclass_transform field specifier params (GH-94354) (GH-94372)
(cherry picked from commit 81ac9ac492)

Co-authored-by: Erik De Bonte <erikd@microsoft.com>
2022-06-28 12:10:42 +02:00
Miss Islington (bot) 3f7abff97b
gh-91243: Document Required and NotRequired (GH-93173)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit 711eda7dec)

Co-authored-by: David Foster <david@dafoster.net>
2022-05-27 15:25:50 -07:00