diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-11-08 14:45:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-08 14:45:17 (GMT) |
commit | 42699c82d7b274c73ab0f3970bf27e2228b813d1 (patch) | |
tree | 2873994195a240f063d37f59a94c3ee90d05ef56 | |
parent | d35c94566ad842d04a4cdeb2cf955f1c9874221e (diff) | |
download | cpython-42699c82d7b274c73ab0f3970bf27e2228b813d1.zip cpython-42699c82d7b274c73ab0f3970bf27e2228b813d1.tar.gz cpython-42699c82d7b274c73ab0f3970bf27e2228b813d1.tar.bz2 |
[3.12] Glossary: Add "static type checker" (GH-111837) (#111854)
Glossary: Add "static type checker" (GH-111837)
(cherry picked from commit 8ab7ad63086b1793c24b1c5aaa19b60fc0e6540e)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
-rw-r--r-- | Doc/glossary.rst | 9 | ||||
-rw-r--r-- | Doc/howto/pyporting.rst | 5 | ||||
-rw-r--r-- | Doc/library/datetime.rst | 3 | ||||
-rw-r--r-- | Doc/library/typing.rst | 4 |
4 files changed, 14 insertions, 7 deletions
diff --git a/Doc/glossary.rst b/Doc/glossary.rst index e43e755..cd34d19 100644 --- a/Doc/glossary.rst +++ b/Doc/glossary.rst @@ -1132,6 +1132,11 @@ Glossary an :term:`expression` or one of several constructs with a keyword, such as :keyword:`if`, :keyword:`while` or :keyword:`for`. + static type checker + An external tool that reads Python code and analyzes it, looking for + issues such as incorrect types. See also :term:`type hints <type hint>` + and the :mod:`typing` module. + strong reference In Python's C API, a strong reference is a reference to an object which is owned by the code holding the reference. The strong @@ -1208,8 +1213,8 @@ Glossary attribute, or a function parameter or return value. Type hints are optional and are not enforced by Python but - they are useful to static type analysis tools, and aid IDEs with code - completion and refactoring. + they are useful to :term:`static type checkers <static type checker>`. + They can also aid IDEs with code completion and refactoring. Type hints of global variables, class attributes, and functions, but not local variables, can be accessed using diff --git a/Doc/howto/pyporting.rst b/Doc/howto/pyporting.rst index 6c30a0d..501b16d 100644 --- a/Doc/howto/pyporting.rst +++ b/Doc/howto/pyporting.rst @@ -39,7 +39,8 @@ are: #. Once your dependencies are no longer blocking you, use continuous integration to make sure you stay compatible with Python 2 and 3 (tox_ can help test against multiple versions of Python; ``python -m pip install tox``) -#. Consider using optional static type checking to make sure your type usage +#. Consider using optional :term:`static type checking <static type checker>` + to make sure your type usage works in both Python 2 and 3 (e.g. use mypy_ to check your typing under both Python 2 and Python 3; ``python -m pip install mypy``). @@ -395,7 +396,7 @@ comparisons occur, making the mistake much easier to track down. Consider using optional static type checking -------------------------------------------- -Another way to help port your code is to use a static type checker like +Another way to help port your code is to use a :term:`static type checker` like mypy_ or pytype_ on your code. These tools can be used to analyze your code as if it's being run under Python 2, then you can run the tool a second time as if your code is running under Python 3. By running a static type checker twice like diff --git a/Doc/library/datetime.rst b/Doc/library/datetime.rst index 04cc755..649f1a3 100644 --- a/Doc/library/datetime.rst +++ b/Doc/library/datetime.rst @@ -38,7 +38,8 @@ on efficient attribute extraction for output formatting and manipulation. Third-party library with expanded time zone and parsing support. Package `DateType <https://pypi.org/project/datetype/>`_ - Third-party library that introduces distinct static types to e.g. allow static type checkers + Third-party library that introduces distinct static types to e.g. allow + :term:`static type checkers <static type checker>` to differentiate between naive and aware datetimes. .. _datetime-naive-aware: diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst index 7cec244..7b75094 100644 --- a/Doc/library/typing.rst +++ b/Doc/library/typing.rst @@ -18,8 +18,8 @@ .. note:: The Python runtime does not enforce function and variable type annotations. - They can be used by third party tools such as type checkers, IDEs, linters, - etc. + They can be used by third party tools such as :term:`type checkers <static type checker>`, + IDEs, linters, etc. -------------- |