Skip to content

Commit

Permalink
Merge branch 'main' into pep702
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra authored Nov 8, 2023
2 parents 0870a16 + 8ab7ad6 commit 2b48983
Show file tree
Hide file tree
Showing 18 changed files with 293 additions and 215 deletions.
4 changes: 2 additions & 2 deletions Doc/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1219,8 +1219,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 :term:`static type checkers <static type checker>`,
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
Expand Down
5 changes: 3 additions & 2 deletions Doc/howto/pyporting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``).

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion Doc/library/datetime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

--------------

Expand Down
39 changes: 21 additions & 18 deletions Include/internal/pycore_opcode_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Lib/test/test_capi/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2712,7 +2712,7 @@ def testfunc(n):
# for i, (opname, oparg) in enumerate(ex):
# print(f"{i:4d}: {opname:<20s} {oparg:3d}")
uops = {opname for opname, _, _ in ex}
self.assertIn("_IS_ITER_EXHAUSTED_RANGE", uops)
self.assertIn("_GUARD_NOT_EXHAUSTED_RANGE", uops)
# Verification that the jump goes past END_FOR
# is done by manual inspection of the output

Expand All @@ -2734,7 +2734,7 @@ def testfunc(a):
# for i, (opname, oparg) in enumerate(ex):
# print(f"{i:4d}: {opname:<20s} {oparg:3d}")
uops = {opname for opname, _, _ in ex}
self.assertIn("_IS_ITER_EXHAUSTED_LIST", uops)
self.assertIn("_GUARD_NOT_EXHAUSTED_LIST", uops)
# Verification that the jump goes past END_FOR
# is done by manual inspection of the output

Expand All @@ -2756,7 +2756,7 @@ def testfunc(a):
# for i, (opname, oparg) in enumerate(ex):
# print(f"{i:4d}: {opname:<20s} {oparg:3d}")
uops = {opname for opname, _, _ in ex}
self.assertIn("_IS_ITER_EXHAUSTED_TUPLE", uops)
self.assertIn("_GUARD_NOT_EXHAUSTED_TUPLE", uops)
# Verification that the jump goes past END_FOR
# is done by manual inspection of the output

Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_type_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import types
import unittest
from test.support import check_syntax_error, run_code
from test import mod_generics_cache
from test.typinganndata import mod_generics_cache

from typing import Callable, TypeAliasType, TypeVar, get_args

Expand Down
3 changes: 1 addition & 2 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
import types

from test.support import captured_stderr, cpython_only, infinite_recursion
from test import mod_generics_cache
from test import _typed_dict_helper
from test.typinganndata import mod_generics_cache, _typed_dict_helper


CANNOT_SUBCLASS_TYPE = 'Cannot subclass special typing classes'
Expand Down
File renamed without changes.
File renamed without changes.
165 changes: 164 additions & 1 deletion Modules/clinic/socketmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2b48983

Please sign in to comment.