Skip to content

Commit c79069b

Browse files
committed
Merge remote-tracking branch 'upstream/master' into intf-impl-parallel
2 parents 0ddd940 + a7bdffd commit c79069b

File tree

130 files changed

+9892
-4793
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+9892
-4793
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repos:
2626
hooks:
2727
- id: codespell
2828
args:
29-
- --ignore-words-list=HAX,ccompiler,ot,statics,whet,zar
29+
- --ignore-words-list=HAX,Nam,ccompiler,ot,statics,whet,zar
3030
exclude: ^(mypy/test/|mypy/typeshed/|mypyc/test-data/|test-data/).+$
3131
- repo: https://github.com/rhysd/actionlint
3232
rev: v1.7.7

CHANGELOG.md

Lines changed: 4771 additions & 4291 deletions
Large diffs are not rendered by default.

MANIFEST.in

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
prune mypy/typeshed
66
include mypy/typeshed/LICENSE
77
include mypy/typeshed/stdlib/VERSIONS
8+
include mypy/typeshed/stdlib/_typeshed/README.md
89
recursive-include mypy/typeshed *.pyi
910

1011
# mypy and mypyc
@@ -38,14 +39,16 @@ include test-requirements.in
3839
include test-requirements.txt
3940
include mypy_self_check.ini
4041
prune misc
42+
include misc/diff-cache.py
43+
include misc/apply-cache-diff.py
4144
graft test-data
4245
graft mypy/test
4346
include conftest.py
4447
include runtests.py
4548
include tox.ini
4649

47-
include LICENSE mypyc/README.md CHANGELOG.md
48-
exclude .gitmodules CONTRIBUTING.md CREDITS ROADMAP.md action.yml .editorconfig
50+
include LICENSE mypyc/README.md CHANGELOG.md CREDITS
51+
exclude .gitmodules CONTRIBUTING.md ROADMAP.md action.yml .editorconfig
4952
exclude .git-blame-ignore-revs .pre-commit-config.yaml
5053

5154
global-exclude *.py[cod]

docs/source/command_line.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ potentially problematic or redundant in some way.
551551
.. note::
552552

553553
Mypy currently cannot detect and report unreachable or redundant code
554-
inside any functions using :ref:`type-variable-value-restriction`.
554+
inside any functions using :ref:`value-constrained type variables <value-constrained-type-variables>`.
555555

556556
This limitation will be removed in future releases of mypy.
557557

@@ -598,7 +598,7 @@ of the above sections.
598598
.. option:: --allow-redefinition-new
599599

600600
By default, mypy won't allow a variable to be redefined with an
601-
unrelated type. This flag enables the redefinition of unannotated
601+
unrelated type. This flag enables the redefinition of *unannotated*
602602
variables with an arbitrary type. You will also need to enable
603603
:option:`--local-partial-types <mypy --local-partial-types>`.
604604
Example:
@@ -645,7 +645,6 @@ of the above sections.
645645
646646
Note: We are planning to turn this flag on by default in a future mypy
647647
release, along with :option:`--local-partial-types <mypy --local-partial-types>`.
648-
The feature is still experimental, and the semantics may still change.
649648

650649
.. option:: --allow-redefinition
651650

@@ -1019,9 +1018,10 @@ beyond what incremental mode can offer, try running mypy in
10191018
writing to the cache, use ``--cache-dir=/dev/null`` (UNIX)
10201019
or ``--cache-dir=nul`` (Windows).
10211020

1022-
.. option:: --sqlite-cache
1021+
.. option:: --no-sqlite-cache
10231022

1024-
Use an `SQLite`_ database to store the cache.
1023+
Avoid using `SQLite`_ database to store the cache, instead write cache data
1024+
out to individual files.
10251025

10261026
.. option:: --cache-fine-grained
10271027

docs/source/common_issues.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,13 @@ See :ref:`type-narrowing` for more information.
303303
Invariance vs covariance
304304
------------------------
305305

306-
Most mutable generic collections are invariant, and mypy considers all
307-
user-defined generic classes invariant by default
308-
(see :ref:`variance-of-generics` for motivation). This could lead to some
306+
Most mutable generic collections are invariant. When using the legacy
307+
``TypeVar`` syntax, mypy considers all user-defined generic classes invariant
308+
by default (see :ref:`variance-of-generics` for motivation). When using the
309+
:pep:`695` syntax (``class MyClass[T]: ...``), variance is inferred from
310+
usage rather than defaulting to invariant.
311+
312+
The fact that mutable sequences are usually invariant can lead to some
309313
unexpected errors when combined with type inference. For example:
310314

311315
.. code-block:: python

docs/source/config_file.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ These options may only be set in the global section (``[mypy]``).
979979
.. confval:: sqlite_cache
980980

981981
:type: boolean
982-
:default: False
982+
:default: True
983983

984984
Use an `SQLite`_ database to store the cache.
985985

docs/source/generics.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -693,10 +693,11 @@ contravariant, use type variables defined with special keyword arguments
693693
my_box = Box(Square())
694694
look_into(my_box) # OK, but mypy would complain here for an invariant type
695695
696+
.. _value-constrained-type-variables:
696697
.. _type-variable-value-restriction:
697698

698-
Type variables with value restriction
699-
*************************************
699+
Value-constrained type variables
700+
*********************************
700701

701702
By default, a type variable can be replaced with any type -- or any type that
702703
is a subtype of the upper bound, which defaults to ``object``. However, sometimes
@@ -727,8 +728,9 @@ The same thing is also possibly using the legacy syntax (Python 3.11 or earlier)
727728
def concat(x: AnyStr, y: AnyStr) -> AnyStr:
728729
return x + y
729730
730-
No matter which syntax you use, such a type variable is called a type variable
731-
with a value restriction. Importantly, this is different from a union type,
731+
No matter which syntax you use, such a type variable is called a
732+
value-constrained type variable (the allowed types are accessible at runtime
733+
via ``TypeVar.__constraints__``). Importantly, this is different from a union type,
732734
since combinations of ``str`` and ``bytes`` are not accepted:
733735

734736
.. code-block:: python
@@ -760,7 +762,7 @@ for the type variable, which in this case is ``str``.
760762

761763
This is thus subtly different from using ``str | bytes`` as an upper bound,
762764
where the return type would be ``S`` (see :ref:`type-variable-upper-bound`).
763-
Using a value restriction is correct for ``concat``, since ``concat``
765+
Using a value constraint is correct for ``concat``, since ``concat``
764766
actually returns a ``str`` instance in the above example:
765767

766768
.. code-block:: python
@@ -775,7 +777,7 @@ value of :py:func:`re.compile`, where ``S`` can be either ``str``
775777
or ``bytes``. Regular expressions can be based on a string or a
776778
bytes pattern.
777779

778-
A type variable may not have both a value restriction and an upper bound.
780+
A type variable may not have both value constraints and an upper bound.
779781

780782
Note that you may come across :py:data:`~typing.AnyStr` imported from
781783
:py:mod:`typing`. This feature is now deprecated, but it means the same
@@ -1330,7 +1332,7 @@ Here are examples using the legacy syntax (Python 3.11 and earlier):
13301332
for i, j in NewVec[int]():
13311333
...
13321334
1333-
Using type variable bounds or value restriction in generic aliases has
1335+
Using type variable bounds or value constraints in generic aliases has
13341336
the same effect as in generic classes and functions.
13351337

13361338

docs/source/more_types.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ Here is the same example using the legacy syntax (Python 3.11 and earlier):
303303
.. note::
304304

305305
If you just need to constrain a type variable to certain types or
306-
subtypes, you can use a :ref:`value restriction
307-
<type-variable-value-restriction>`.
306+
subtypes, you can use a :ref:`value-constrained type variable
307+
<value-constrained-type-variables>`.
308308

309309
The default values of a function's arguments don't affect its signature -- only
310310
the absence or presence of a default value does. So in order to reduce

docs/source/stubtest.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ The rest of this section documents the command line interface of stubtest.
183183

184184
Ignore errors for whether an argument should or shouldn't be positional-only
185185

186+
.. option:: --strict-type-check-only
187+
188+
Require :py:func:`@type_check_only <typing.type_check_only>` on private types
189+
that are not present at runtime.
190+
186191
.. option:: --allowlist FILE
187192

188193
Use file as an allowlist. Can be passed multiple times to combine multiple

misc/generate_changelog.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def filter_omitted_commits(commits: list[CommitInfo]) -> list[CommitInfo]:
8383
):
8484
# These are generated by a typeshed sync.
8585
keep = False
86-
if re.search(r"(bump|update).*version.*\+dev", title.lower()):
86+
if re.search(r"(bump|update).*version", title.lower()):
8787
# Version number updates aren't mentioned
8888
keep = False
8989
if "pre-commit autoupdate" in title:
@@ -155,13 +155,19 @@ def format_changelog_entry(c: CommitInfo) -> str:
155155

156156

157157
def main() -> None:
158-
parser = argparse.ArgumentParser()
158+
parser = argparse.ArgumentParser(
159+
description="Generate draft .md changelog for a mypy public release and print it to stdout."
160+
)
159161
parser.add_argument("version", help="target mypy version (form X.Y)")
160-
parser.add_argument("--local", action="store_true")
162+
parser.add_argument(
163+
"--local", action="store_true", help="use local release branch, not origin"
164+
)
161165
args = parser.parse_args()
162166
version: str = args.version
163167
local: bool = args.local
164168

169+
version = version.removeprefix("v")
170+
165171
if not re.match(r"[0-9]+\.[0-9]+$", version):
166172
sys.exit(f"error: Release must be of form X.Y (not {version!r})")
167173
major, minor = (int(component) for component in version.split("."))
@@ -187,7 +193,10 @@ def main() -> None:
187193
print(f"Generating changelog for {major}.{minor}")
188194
print(f"Previous release was {prev_major}.{prev_minor}")
189195

190-
new_branch = f"origin/release-{major}.{minor}"
196+
if local:
197+
new_branch = f"release-{major}.{minor}"
198+
else:
199+
new_branch = f"origin/release-{major}.{minor}"
191200
old_branch = f"origin/release-{prev_major}.{prev_minor}"
192201

193202
changes = find_changes_between_releases(old_branch, new_branch)

0 commit comments

Comments
 (0)