blob: b5fe26888c72ae6d155c0a333f37cef13aaa8a63 [file] [log] [blame]
Sebastian Rittau651cb582021-08-24 23:44:46 +02001*************************
2Static Typing with Python
3*************************
Sebastian Rittauae263342021-12-22 17:00:56 +01004
5.. Introduction
6.. ============
Redowan Delowar91691522022-04-11 08:27:03 +06007..
Stephen Rosen9c7e30b2021-12-22 05:40:33 -05008.. .. toctree::
9.. :maxdepth: 2
Redowan Delowar91691522022-04-11 08:27:03 +060010..
Stephen Rosen9c7e30b2021-12-22 05:40:33 -050011.. source/introduction
Shannon Zhu80cfad02021-12-21 10:21:27 -080012
Sebastian Rittauae263342021-12-22 17:00:56 +010013Guides
14======
15
Shannon Zhu80cfad02021-12-21 10:21:27 -080016.. toctree::
Sebastian Rittauae263342021-12-22 17:00:56 +010017 :maxdepth: 2
18
19 source/guides
20
21Reference
22=========
23
24.. toctree::
25 :maxdepth: 2
Shannon Zhu80cfad02021-12-21 10:21:27 -080026
27 source/reference
Shannon Zhu2de0a932021-06-03 18:53:01 -070028
Shannon Zhu2de0a932021-06-03 18:53:01 -070029Indices and tables
30==================
31
32* :ref:`genindex`
Shannon Zhu2de0a932021-06-03 18:53:01 -070033* :ref:`search`
Sebastian Rittau9e1e4472021-08-23 23:20:19 +020034
Sebastian Rittauc7c30c82021-08-24 08:40:48 +020035Discussions and Support
36=======================
37
38* `User help forum <https://github.com/python/typing/discussions>`_
39* `User chat on Gitter <http://gitter.im/python/typing>`_
40* `Developer mailing list <https://mail.python.org/archives/list/typing-sig@python.org/>`_
41
Sebastian Rittau9e1e4472021-08-23 23:20:19 +020042Typing-related Tools
43====================
44
45Type Checkers
46-------------
47
48* `mypy <http://mypy-lang.org/>`_, the reference implementation for type
49 checkers. Supports Python 2 and 3.
50* `pyre <https://pyre-check.org/>`_, written in OCaml and optimized for
51 performance. Supports Python 3 only.
52* `pyright <https://github.com/microsoft/pyright>`_, a type checker that
53 emphasizes speed. Supports Python 3 only.
54* `pytype <https://google.github.io/pytype/>`_, checks and infers types for
55 unannotated code. Supports Python 2 and 3.
56
57Development Environments
58------------------------
59
Numerlor345e8922021-11-27 07:42:08 -080060* `PyCharm <https://www.jetbrains.com/pycharm/>`_, an IDE that supports
Sebastian Rittau9e1e4472021-08-23 23:20:19 +020061 type stubs both for type checking and code completion.
62* `Visual Studio Code <https://code.visualstudio.com/>`_, a code editor that
63 supports type checking using mypy, pyright, or the
64 `Pylance <https://marketplace.visualstudio.com/items?itemName=ms-python.vscode-pylance>`_
65 extension.
66
67Linters and Formatters
68----------------------
69
70* `black <https://black.readthedocs.io/>`_, a code formatter with support for
71 type stub files.
72* `flake8-pyi <https://github.com/ambv/flake8-pyi>`_, a plugin for the
73 `flake8 <https://flake8.pycqa.org/>`_ linter that adds support for type
74 stubs.
Jelle Zijlstra37aa31f2021-11-19 00:46:35 -080075
76Typing PEPs
77===========
78
Sebastian Rittaufefa5352021-11-19 14:16:21 +010079* `PEP 483 <https://www.python.org/dev/peps/pep-0483/>`_, background on type hints
80* `PEP 484 <https://www.python.org/dev/peps/pep-0484/>`_, type hints
81* `PEP 526 <https://www.python.org/dev/peps/pep-0526/>`_, variable annotations and ``ClassVar``
82* `PEP 544 <https://www.python.org/dev/peps/pep-0544/>`_, ``Protocol``
83* `PEP 561 <https://www.python.org/dev/peps/pep-0561/>`_, distributing typed packages
84* `PEP 563 <https://www.python.org/dev/peps/pep-0563/>`_, ``from __future__ import annotations``
85* `PEP 585 <https://www.python.org/dev/peps/pep-0585/>`_, subscriptable generics in the standard library
86* `PEP 586 <https://www.python.org/dev/peps/pep-0586/>`_, ``Literal``
87* `PEP 589 <https://www.python.org/dev/peps/pep-0589/>`_, ``TypedDict``
88* `PEP 591 <https://www.python.org/dev/peps/pep-0591/>`_, ``Final``
89* `PEP 593 <https://www.python.org/dev/peps/pep-0593/>`_, ``Annotated``
90* `PEP 604 <https://www.python.org/dev/peps/pep-0604/>`_, union syntax with ``|``
91* `PEP 612 <https://www.python.org/dev/peps/pep-0612/>`_, ``ParamSpec``
92* `PEP 613 <https://www.python.org/dev/peps/pep-0613/>`_, ``TypeAlias``
93* `PEP 646 <https://www.python.org/dev/peps/pep-0646/>`_, variadic generics and ``TypeVarTuple``
94* `PEP 647 <https://www.python.org/dev/peps/pep-0647/>`_, ``TypeGuard``
Redowan Delowar91691522022-04-11 08:27:03 +060095* `PEP 655 <https://www.python.org/dev/peps/pep-0655/>`_, ``Required`` and ``NotRequired``
Jelle Zijlstraa45c7e92022-02-09 18:16:06 -080096* `PEP 673 <https://www.python.org/dev/peps/pep-0673/>`_, ``Self``
Redowan Delowar91691522022-04-11 08:27:03 +060097* `PEP 675 <https://www.python.org/dev/peps/pep-0675/>`_, ``LiteralString``
98* `PEP 677 <https://www.python.org/dev/peps/pep-0677/>`_ (rejected), callable type syntax
Jelle Zijlstrac1db1372022-02-09 18:18:43 -080099* `PEP 681 <https://www.python.org/dev/peps/pep-0681/>`_ (draft), ``@dataclass_transform()``