[med-svn] [Git][python-team/packages/mypy][master] 8 commits: Packaging update (routine-update)

Michael R. Crusoe (@crusoe) gitlab at salsa.debian.org
Thu Oct 29 14:59:47 GMT 2026



Michael R. Crusoe pushed to branch master at Debian Python Team / packages / mypy


Commits:
821b8a5a by Michael R. Crusoe at 2026-10-29T13:47:03+01:00
Packaging update (routine-update)

- - - - -
9ba29196 by Michael R. Crusoe at 2026-10-29T13:47:11+01:00
New upstream version 2.4.1
- - - - -
bce8de19 by Michael R. Crusoe at 2026-10-29T13:47:11+01:00
New upstream version

- - - - -
3f3f2afa by Michael R. Crusoe at 2026-10-29T13:47:29+01:00
Update upstream source from tag 'upstream/2.4.1'

Update to upstream version '2.4.1'
with Debian dir bf19d7cb61b7013765e1ba6650c2881e2390128e
- - - - -
d1b83f31 by Michael R. Crusoe at 2026-10-29T13:49:45+01:00
d/control: reformat, upgrade to debhelper 14

- - - - -
76ca0c74 by Michael R. Crusoe at 2026-10-29T13:49:58+01:00
Remove redundant relation in debian/control.

Changes-By: lintian-brush
Fixes: lintian: source: redundant-control-relation (in source paragraph) Build-Depends python3-typeshed <!nocheck>
See-also: https://lintian.debian.org/tags/redundant-control-relation.html

- - - - -
15cc748f by Michael R. Crusoe at 2026-10-29T13:50:00+01:00
Dropped a patch that was applied upstream.

- - - - -
c0555920 by Michael R. Crusoe at 2026-10-29T15:54:38+01:00
d/watch: update to format version 5

- - - - -


24 changed files:

- CHANGELOG.md
- PKG-INFO
- debian/changelog
- debian/control
- − debian/patches/0001-mypyc-Fix-recursive-setup-for-frame-private-helpers.patch
- debian/patches/series
- debian/watch
- mypy-requirements.txt
- mypy.egg-info/PKG-INFO
- mypy.egg-info/requires.txt
- mypy/semanal.py
- mypy/version.py
- mypyc/irbuild/env_class.py
- mypyc/irbuild/function.py
- mypyc/irbuild/generator.py
- mypyc/irbuild/util.py
- mypyc/test-data/run-functions.test
- mypyc/test-data/run-generators.test
- mypyc/test/test_generator_spills.py
- pyproject.toml
- test-data/unit/check-classes.test
- test-data/unit/check-errorcodes.test
- test-data/unit/native-parser.test
- test-requirements.txt


Changes:

=====================================
CHANGELOG.md
=====================================
@@ -259,6 +259,11 @@ Related changes:
 
 Please see [git log](https://github.com/python/typeshed/commits/main?after=6d045a9fff15db83b49b89b14b8dd47ff382470c+0&branch=main&path=stdlib) for the full list of standard library typeshed stub changes.
 
+### Mypy 2.4.1
+
+- Process overloads as a whole in two-phase type checking (Ivan Levkivskyi, PR [22231](https://github.com/python/mypy/pull/22231))
+- Skip recursive setup for frame-private nested functions in mypyc (Piotr Sawicki, PR [22187](https://github.com/python/mypy/pull/22187))
+
 ### Acknowledgements
 
 Thanks to all mypy contributors who contributed to this release:


=====================================
PKG-INFO
=====================================
@@ -1,6 +1,6 @@
 Metadata-Version: 2.4
 Name: mypy
-Version: 2.4.0
+Version: 2.4.1
 Summary: Optional static typing for Python
 Author-email: Jukka Lehtosalo <jukka.lehtosalo at iki.fi>
 License-Expression: MIT
@@ -31,7 +31,7 @@ Requires-Dist: mypy_extensions>=1.0.0
 Requires-Dist: pathspec>=1.0.0
 Requires-Dist: tomli>=1.1.0; python_version < "3.11"
 Requires-Dist: librt>=0.16.0; platform_python_implementation != "PyPy"
-Requires-Dist: ast-serialize<1.0.0,>=0.11.2
+Requires-Dist: ast-serialize<1.0.0,>=0.12.1
 Provides-Extra: dmypy
 Requires-Dist: psutil>=4.0; extra == "dmypy"
 Provides-Extra: mypyc


=====================================
debian/changelog
=====================================
@@ -1,3 +1,14 @@
+mypy (2.4.1-1) UNRELEASED; urgency=medium
+
+  * Packaging update (routine-update)
+  * New upstream version
+  * d/control: reformat, upgrade to debhelper 14
+  * Remove redundant relation in debian/control.
+  * Dropped a patch that was applied upstream.
+  * d/watch: update to format version 5
+
+ -- Michael R. Crusoe <crusoe at debian.org>  Thu, 29 Oct 2026 13:47:11 +0100
+
 mypy (2.4.0-4) unstable; urgency=medium
 
   * Team upload.


=====================================
debian/control
=====================================
@@ -6,43 +6,42 @@ Uploaders:
 Section: utils
 Testsuite: autopkgtest-pkg-pybuild
 Build-Depends:
- debhelper-compat (= 13),
+ debhelper-compat (= 14),
  dh-sequence-python3,
  dh-sequence-sphinxdoc <!nodoc>,
+ cython-doc <!nodoc>,
  dh-python (>= 6.20251221),
- python3-setuptools (>= 77.0.3),
- pybuild-plugin-pyproject,
  flake8 <!nocheck>,
+ furo <!nodoc>,
  help2man,
+ libpython3-all-dev,
+ pybuild-plugin-pyproject,
+ python-attr-doc <!nodoc>,
+ python-setuptools-doc <!nodoc>,
+ python-six-doc <!nodoc>,
  python3-all,
+ python3-all-dev:native,
+ python3-all-venv <!nocheck>,
  python3-ast-serialize (>= 0.13.0),
+ python3-attr <!nocheck>,
+ python3-doc <!nodoc>,
  python3-librt,
  python3-lxml,
- python3-attr <!nocheck>,
+ python3-mypy-extensions (>= 1.0.0),
+ python3-myst-parser <!nodoc>,
+ python3-orjson [!i386 !alpha !hppa !m68k !sh4 !x32] <!nocheck>,
  python3-pathspec (>= 1),
+ python3-psutil,
  python3-pytest (>= 8.1.0) <!nocheck>,
- python3-pytest-xdist <!nocheck>,
  python3-pytest-cov <!nocheck>,
+ python3-pytest-xdist <!nocheck>,
+ python3-setuptools (>= 77.0.3),
  python3-sphinx <!nodoc>,
- furo <!nodoc>,
+ python3-sphinx-inline-tabs <!nodoc>,
+ python3-tomli <!nocheck>,
  python3-typeshed,
- python3-psutil,
- python3-mypy-extensions (>= 1.0.0),
  python3-typing-extensions (>= 4.16.0),
  python3-virtualenv <!nocheck>,
- python3-typeshed <!nocheck>,
- python3-all-dev:native,
- libpython3-all-dev,
- python3-tomli <!nocheck>,
- python3-all-venv <!nocheck>,
- python3-doc <!nodoc>,
- cython-doc <!nodoc>,
- python-six-doc <!nodoc>,
- python-setuptools-doc <!nodoc>,
- python-attr-doc <!nodoc>,
- python3-myst-parser <!nodoc>,
- python3-sphinx-inline-tabs <!nodoc>,
- python3-orjson [!i386 !alpha !hppa !m68k !sh4 !x32] <!nocheck>,
 Vcs-Browser: https://salsa.debian.org/python-team/packages/mypy
 Vcs-Git: https://salsa.debian.org/python-team/packages/mypy.git
 Homepage: https://www.mypy-lang.org/
@@ -50,9 +49,9 @@ Homepage: https://www.mypy-lang.org/
 Package: mypy
 Architecture: all
 Depends:
+ python3-mypy (>= ${binary:Version}),
  ${misc:Depends},
  ${python3:Depends},
- python3-mypy (>= ${binary:Version}),
 Recommends:
  python3-typeshed,
 Suggests:
@@ -74,11 +73,11 @@ Depends:
  ${misc:Depends},
  ${sphinxdoc:Depends},
 Recommends:
- python3-doc,
  cython-doc,
- python-six-doc,
- python-setuptools-doc,
  python-attr-doc,
+ python-setuptools-doc,
+ python-six-doc,
+ python3-doc,
 Built-Using:
  ${sphinxdoc:Built-Using},
 Description: documentation for mypy
@@ -95,16 +94,16 @@ Package: python3-mypy
 Architecture: any
 Section: python
 Depends:
+ python3-librt,
+ python3-mypy-extensions (>= 1.0.0),
+ python3-psutil,
  ${misc:Depends},
  ${python3:Depends},
  ${shlibs:Depends},
- python3-mypy-extensions (>= 1.0.0),
- python3-psutil,
- python3-librt,
 Recommends:
  python3-lxml,
- python3-setuptools,
  python3-orjson [!i386 !alpha !hppa !m68k !sh4 !x32],
+ python3-setuptools,
 Breaks:
  python3-pytest-mypy (<= 4.0.3-5),
 Description: public modules for mypy (Python 3)


=====================================
debian/patches/0001-mypyc-Fix-recursive-setup-for-frame-private-helpers.patch deleted
=====================================
@@ -1,334 +0,0 @@
-From: Piotr Sawicki <sawickipiotr at outlook.com>
-Date: Tue, 13 Oct 2026 13:45:14 +0200
-Subject: [mypyc] Skip recursive setup for frame-private nested functions
- (#22187)
-
-Origin: upstream, https://github.com/python/mypy/pull/22187/
-Forwared: not-needed
-
-
-The recursive setup could cause `AttributeError` at runtime when a
-function contains both a frame-private as well as a captured nested
-function. The setup would add the frame-private function object as an
-attribute to the env class and access it even though it was never
-initialized.
-
-Fix by omitting the recursive setup since it's not needed - a
-frame-private nested function can't call itself.
-
-Also fix possibly inconsistent storage for a redefined nested function
-that is captured in one branch and not captured in another by using
-`original_def` in capture/free variable checks.
----
- mypyc/irbuild/env_class.py          | 36 +++++++++++++++++---------
- mypyc/irbuild/function.py           |  8 +++---
- mypyc/irbuild/generator.py          |  4 +--
- mypyc/irbuild/util.py               |  8 ++++++
- mypyc/test-data/run-functions.test  | 27 ++++++++++++++++++++
- mypyc/test-data/run-generators.test | 32 ++++++++++++++++++++++++
- mypyc/test/test_generator_spills.py | 50 +++++++++++++++++++++++++++++++++++++
- 7 files changed, 146 insertions(+), 19 deletions(-)
-
-diff --git a/mypyc/irbuild/env_class.py b/mypyc/irbuild/env_class.py
-index 4e5c581..42d2fac 100644
---- a/mypyc/irbuild/env_class.py
-+++ b/mypyc/irbuild/env_class.py
-@@ -31,6 +31,7 @@ from mypyc.ir.rtypes import RInstance, bitmap_rprimitive, object_rprimitive
- from mypyc.irbuild.builder import IRBuilder, SymbolTarget
- from mypyc.irbuild.context import FuncInfo, GeneratorClass, ImplicitClass
- from mypyc.irbuild.targets import AssignmentTargetAttr
-+from mypyc.irbuild.util import get_func_target_symbol
- 
- 
- def setup_env_class(builder: IRBuilder) -> ClassIR:
-@@ -141,7 +142,7 @@ def load_env_registers(builder: IRBuilder, prefix: str = "") -> None:
-         # If this is a FuncDef, then make sure to load the FuncDef into its own environment
-         # class so that the function can be called recursively.
-         if isinstance(fitem, FuncDef) and fn_info.add_nested_funcs_to_env:
--            setup_func_for_recursive_call(builder, fitem, fn_info.callable_class, prefix=prefix)
-+            setup_func_for_recursive_call(builder, fitem, fn_info.callable_class)
- 
- 
- def load_outer_env(
-@@ -298,8 +299,13 @@ def add_vars_to_env(builder: IRBuilder, prefix: str = "") -> None:
-                 )
- 
-     if fn_info.fitem in builder.encapsulating_funcs:
-+        added: set[SymbolNode] = set()
-         for nested_fn in builder.encapsulating_funcs[fn_info.fitem]:
-             if isinstance(nested_fn, FuncDef):
-+                target_symbol = get_func_target_symbol(nested_fn)
-+                if target_symbol in added:
-+                    continue
-+                added.add(target_symbol)
-                 # The return type is 'object' instead of an RInstance of the
-                 # callable class because differently defined functions with
-                 # the same name and signature across conditional blocks
-@@ -308,10 +314,10 @@ def add_vars_to_env(builder: IRBuilder, prefix: str = "") -> None:
-                 nested_prefix = prefix
-                 if nested_fn.is_generator or nested_fn.is_coroutine:
-                     nested_prefix = GENERATOR_ATTRIBUTE_PREFIX
--                keep_alive = is_free_variable(builder, nested_fn)
--                if fn_info.is_generator and not builder.is_captured_by_nested_func(nested_fn):
-+                keep_alive = is_free_variable(builder, target_symbol)
-+                if fn_info.is_generator and not builder.is_captured_by_nested_func(target_symbol):
-                     builder.add_var_to_generator_frame(
--                        nested_fn,
-+                        target_symbol,
-                         object_rprimitive,
-                         fn_info.generator_class.self_reg,
-                         reassign=False,
-@@ -319,7 +325,7 @@ def add_vars_to_env(builder: IRBuilder, prefix: str = "") -> None:
-                     )
-                 else:
-                     builder.add_var_to_env_class(
--                        nested_fn,
-+                        target_symbol,
-                         object_rprimitive,
-                         env_for_func,
-                         reassign=False,
-@@ -328,9 +334,7 @@ def add_vars_to_env(builder: IRBuilder, prefix: str = "") -> None:
-                     )
- 
- 
--def setup_func_for_recursive_call(
--    builder: IRBuilder, fdef: FuncDef, base: ImplicitClass, prefix: str = ""
--) -> None:
-+def setup_func_for_recursive_call(builder: IRBuilder, fdef: FuncDef, base: ImplicitClass) -> None:
-     """Enable calling a nested function (with a callable class) recursively.
- 
-     Adds the instance of the callable class representing the given
-@@ -338,10 +342,18 @@ def setup_func_for_recursive_call(
-     be called recursively. Note that this needs to be done only for
-     nested functions.
-     """
--    # First, set the attribute of the environment class so that GetAttr can be called on it.
-     prev_env = builder.fn_infos[-2].env_class
--    attr_name = prefix + fdef.name
--    prev_env.attributes[attr_name] = builder.type_to_rtype(fdef.type)
-+    target_symbol = get_func_target_symbol(fdef)
-+    target = builder.symtables[-2].get(target_symbol)
-+    if (
-+        not isinstance(target_symbol, FuncDef)
-+        or not isinstance(target, AssignmentTargetAttr)
-+        or not isinstance(target.obj.type, RInstance)
-+        or target.obj.type.class_ir is not prev_env
-+    ):
-+        return
-+
-+    attr_name = target.attr
-     line = fdef.line
- 
-     if isinstance(base, GeneratorClass):
-@@ -355,7 +367,7 @@ def setup_func_for_recursive_call(
-     # Obtain the instance of the callable class representing the FuncDef, and add it to the
-     # current environment.
-     val = builder.add(GetAttr(prev_env_reg, attr_name, line))
--    target = builder.add_local_reg(fdef, object_rprimitive)
-+    target = builder.add_local_reg(target_symbol, object_rprimitive)
-     builder.assign(target, val, line)
- 
- 
-diff --git a/mypyc/irbuild/function.py b/mypyc/irbuild/function.py
-index 588e1cd..2b12b25 100644
---- a/mypyc/irbuild/function.py
-+++ b/mypyc/irbuild/function.py
-@@ -77,6 +77,7 @@ from mypyc.irbuild.env_class import (
- )
- from mypyc.irbuild.generator import gen_generator_func, gen_generator_func_body
- from mypyc.irbuild.targets import AssignmentTarget
-+from mypyc.irbuild.util import get_func_target_symbol
- from mypyc.primitives.dict_ops import (
-     dict_get_method_with_none,
-     dict_new_op,
-@@ -925,11 +926,10 @@ def get_func_target(builder: IRBuilder, fdef: FuncDef) -> AssignmentTarget:
-     If the function was not already defined somewhere, then define it
-     and add it to the current environment.
-     """
--    if orig := fdef.original_def:
--        if isinstance(orig, Decorator):
--            orig = orig.func
-+    target_symbol = get_func_target_symbol(fdef)
-+    if target_symbol is not fdef:
-         # Get the target associated with the previously defined FuncDef.
--        return builder.lookup(orig)
-+        return builder.lookup(target_symbol)
- 
-     if builder.fn_info.is_generator or builder.fn_info.add_nested_funcs_to_env:
-         return builder.lookup(fdef)
-diff --git a/mypyc/irbuild/generator.py b/mypyc/irbuild/generator.py
-index 7cd4f7d..86d4d40 100644
---- a/mypyc/irbuild/generator.py
-+++ b/mypyc/irbuild/generator.py
-@@ -111,9 +111,7 @@ def gen_generator_func_body(builder: IRBuilder, fn_info: FuncInfo, func_reg: Val
-         and top_level
-         and top_level.add_nested_funcs_to_env
-     ):
--        setup_func_for_recursive_call(
--            builder, fitem, builder.fn_info.generator_class, prefix=GENERATOR_ATTRIBUTE_PREFIX
--        )
-+        setup_func_for_recursive_call(builder, fitem, builder.fn_info.generator_class)
-     cleanup_on_error = BasicBlock()
-     builder.builder.push_error_handler(cleanup_on_error)
-     create_switch_for_generator_class(builder)
-diff --git a/mypyc/irbuild/util.py b/mypyc/irbuild/util.py
-index a2378fa..5c53391 100644
---- a/mypyc/irbuild/util.py
-+++ b/mypyc/irbuild/util.py
-@@ -346,6 +346,14 @@ def get_func_def(op: FuncDef | Decorator | OverloadedFuncDef) -> FuncDef:
-     return op
- 
- 
-+def get_func_target_symbol(fdef: FuncDef) -> FuncDef | Var:
-+    """Return the symbol used to store a possibly redefined function."""
-+    original = fdef.original_def
-+    if isinstance(original, Decorator):
-+        return original.func
-+    return original or fdef
-+
-+
- def concrete_arg_kind(kind: ArgKind) -> ArgKind:
-     """Find the concrete version of an arg kind that is being passed."""
-     if kind == ARG_OPT:
-diff --git a/mypyc/test-data/run-functions.test b/mypyc/test-data/run-functions.test
-index b0f184c..bb52eeb 100644
---- a/mypyc/test-data/run-functions.test
-+++ b/mypyc/test-data/run-functions.test
-@@ -1399,6 +1399,33 @@ print(f(1))
- [out]
- 2
- 
-+[case testReassignedNestedFunction]
-+from typing import Callable, Generator
-+
-+def outer(flag: bool) -> list[int]:
-+    out: list[int] = []
-+    f: Callable[[int], None] = lambda n: out.append(-1)
-+
-+    def swap() -> None:
-+        nonlocal f
-+        f = lambda n: out.append(100 + n)
-+
-+    if flag:
-+        def f(n: int) -> None:
-+            def k(m: int) -> int:
-+                return k(m - 1) if m else 0
-+
-+            out.append(n + k(2))
-+            if n == 0:
-+                swap()
-+                f(1)   # should call the lambda installed by swap()
-+    f(0)
-+    return out
-+
-+def test_reassigned_nested_function() -> None:
-+    assert outer(False) == [-1]
-+    assert outer(True) == [0, 101]
-+
- [case testStarArgFastPaths]
- from typing import Any, Mapping
- def fn(x: str, y: int) -> str:
-diff --git a/mypyc/test-data/run-generators.test b/mypyc/test-data/run-generators.test
-index b881079..70f3e80 100644
---- a/mypyc/test-data/run-generators.test
-+++ b/mypyc/test-data/run-generators.test
-@@ -825,6 +825,38 @@ def test_nested_generator_private_spill() -> None:
-     assert yields == ("right",)
-     assert value == "capturedleftsent"
- 
-+[case testNestedGeneratorPrivateHelper]
-+from typing import Iterator
-+
-+def outer() -> Iterator[int]:
-+    def captured() -> Iterator[int]:
-+        yield 1
-+
-+    def private() -> Iterator[int]:
-+        yield from captured()
-+
-+    yield from private()
-+
-+def test_nested_generator_private_helper() -> None:
-+    assert list(outer()) == [1]
-+
-+[case testRedefinedNestedGeneratorHelper]
-+from typing import Iterator
-+
-+def redefined_nested_helper(flag: bool) -> Iterator[int]:
-+    if flag:
-+        def helper(n: int) -> int:
-+            return 1
-+    else:
-+        def helper(n: int) -> int:
-+            return helper(1) if not n else 2
-+
-+    yield helper(0)
-+
-+def test_redefined_nested_generator_helper() -> None:
-+    assert list(redefined_nested_helper(True)) == [1]
-+    assert list(redefined_nested_helper(False)) == [2]
-+
- [case testGeneratorPrivateAndEscapedBindings]
- from typing import Any, Callable, Generator, Iterator
- 
-diff --git a/mypyc/test/test_generator_spills.py b/mypyc/test/test_generator_spills.py
-index a6e0618..462d2a7 100644
---- a/mypyc/test/test_generator_spills.py
-+++ b/mypyc/test/test_generator_spills.py
-@@ -184,6 +184,56 @@ def gen() -> Iterator[Any]:
-         )
-         assert environment is not frame
- 
-+    def test_nested_generator_private_helper_stays_on_frame(self) -> None:
-+        module, _, _, _ = build_ir_for_single_file2("""\
-+from typing import Iterator
-+
-+def outer() -> Iterator[int]:
-+    def captured() -> Iterator[int]:
-+        yield 1
-+    def private() -> Iterator[int]:
-+        yield from captured()
-+    yield from private()
-+""".splitlines())
-+        outer_frame = next(cl for cl in module.classes if cl.name == "outer_gen")
-+        environment_type = outer_frame.attributes[ENV_ATTR_NAME]
-+        assert isinstance(environment_type, RInstance)
-+        environment = environment_type.class_ir
-+
-+        assert GENERATOR_ATTRIBUTE_PREFIX + "captured" in environment.attributes
-+        assert "private" in frame_variables(outer_frame)
-+        assert GENERATOR_ATTRIBUTE_PREFIX + "private" not in environment.attributes
-+
-+        private_frame = next(cl for cl in module.classes if cl.name.startswith("private_gen___"))
-+        private_helper = private_frame.env_user_function
-+        assert private_helper is not None
-+        assert not any(
-+            isinstance(op, GetAttr) and op.attr == GENERATOR_ATTRIBUTE_PREFIX + "private"
-+            for block in private_helper.blocks
-+            for op in block.ops
-+        )
-+
-+    def test_redefined_nested_helper_has_single_storage_location(self) -> None:
-+        module, _, _, _ = build_ir_for_single_file2("""\
-+from typing import Iterator
-+
-+def outer(flag: bool) -> Iterator[int]:
-+    if flag:
-+        def helper(n: int) -> int:
-+            return 1
-+    else:
-+        def helper(n: int) -> int:
-+            return helper(1) if not n else 2
-+    yield helper(0)
-+""".splitlines())
-+        outer_frame = next(cl for cl in module.classes if cl.name == "outer_gen")
-+        environment_type = outer_frame.attributes[ENV_ATTR_NAME]
-+        assert isinstance(environment_type, RInstance)
-+        environment = environment_type.class_ir
-+
-+        assert GENERATOR_ATTRIBUTE_PREFIX + "helper" in environment.attributes
-+        assert "helper" not in frame_variables(outer_frame)
-+
-     def test_nested_finally_promotes_each_saved_exception(self) -> None:
-         cl = generator_class(
-             """\


=====================================
debian/patches/series
=====================================
@@ -1,4 +1,3 @@
-0001-mypyc-Fix-recursive-setup-for-frame-private-helpers.patch
 0002-Bump-ast-serialize-to-0.13.0.patch
 remove-mypyc-test-run-timeout
 hint-typeshed-package


=====================================
debian/watch
=====================================
@@ -1,3 +1,4 @@
-version=4
-opts=uversionmangle=s/(rc|a|b|c)/~$1/ \
-https://pypi.debian.net/mypy/mypy-(.+)\.(?:zip|tgz|tbz|txz|(?:tar\.(?:gz|bz2|xz)))
+Version: 5
+
+Template: Pypi
+Dist: mypy


=====================================
mypy-requirements.txt
=====================================
@@ -6,4 +6,4 @@ mypy_extensions>=1.0.0
 pathspec>=1.0.0
 tomli>=1.1.0; python_version<'3.11'
 librt>=0.16.0; platform_python_implementation != 'PyPy'
-ast-serialize>=0.11.2,<1.0.0
+ast-serialize>=0.12.1,<1.0.0


=====================================
mypy.egg-info/PKG-INFO
=====================================
@@ -1,6 +1,6 @@
 Metadata-Version: 2.4
 Name: mypy
-Version: 2.4.0
+Version: 2.4.1
 Summary: Optional static typing for Python
 Author-email: Jukka Lehtosalo <jukka.lehtosalo at iki.fi>
 License-Expression: MIT
@@ -31,7 +31,7 @@ Requires-Dist: mypy_extensions>=1.0.0
 Requires-Dist: pathspec>=1.0.0
 Requires-Dist: tomli>=1.1.0; python_version < "3.11"
 Requires-Dist: librt>=0.16.0; platform_python_implementation != "PyPy"
-Requires-Dist: ast-serialize<1.0.0,>=0.11.2
+Requires-Dist: ast-serialize<1.0.0,>=0.12.1
 Provides-Extra: dmypy
 Requires-Dist: psutil>=4.0; extra == "dmypy"
 Provides-Extra: mypyc


=====================================
mypy.egg-info/requires.txt
=====================================
@@ -1,6 +1,6 @@
 mypy_extensions>=1.0.0
 pathspec>=1.0.0
-ast-serialize<1.0.0,>=0.11.2
+ast-serialize<1.0.0,>=0.12.1
 
 [:platform_python_implementation != "PyPy"]
 librt>=0.16.0


=====================================
mypy/semanal.py
=====================================
@@ -4713,7 +4713,7 @@ class SemanticAnalyzer(
                 and original_def.node.is_inferred
             ):
                 for func in self.scope.functions:
-                    func.def_or_infer_vars = True
+                    mark_as_top_level(func)
 
     def analyze_tuple_or_list_lvalue(self, lval: TupleExpr, explicit_type: bool = False) -> None:
         """Analyze an lvalue or assignment target that is a list or tuple."""
@@ -4798,7 +4798,7 @@ class SemanticAnalyzer(
                     # TODO: should we also set lval.kind = MDEF?
                     self.type.names[lval.name] = SymbolTableNode(MDEF, v, implicit=True)
                     for func in self.scope.functions:
-                        func.def_or_infer_vars = True
+                        mark_as_top_level(func)
 
         if self.is_self_member_ref(lval) or self.is_cls_member_ref(lval):
             assert self.type, "Self or cls member outside a class"
@@ -4810,7 +4810,7 @@ class SemanticAnalyzer(
                 and cur_node.node.is_initialized_in_class
             ):
                 for func in self.scope.functions:
-                    func.def_or_infer_vars = True
+                    mark_as_top_level(func)
         self.check_lvalue_validity(lval.node, lval)
 
     def is_self_member_ref(self, memberexpr: MemberExpr) -> bool:
@@ -8598,6 +8598,18 @@ def erase_func_annotations(func: FuncDef) -> None:
     func.unanalyzed_type = None
 
 
+def mark_as_top_level(func: FuncBase) -> None:
+    """Mark a function to be processed as part of module top level.
+
+    A non-trivial part here is that we want to keep overloads as a whole.
+    """
+    func.def_or_infer_vars = True
+    if isinstance(func, OverloadedFuncDef):
+        for item in func.items:
+            defn = item if isinstance(item, FuncDef) else item.func
+            defn.def_or_infer_vars = True
+
+
 def dotted_identifier_leftmost(s: str) -> str | None:
     """The leftmost component of s, if s is a dotted identifier, else None.
 


=====================================
mypy/version.py
=====================================
@@ -8,7 +8,7 @@ from mypy import git
 # - Release versions have the form "1.2.3".
 # - Dev versions have the form "1.2.3+dev" (PLUS sign to conform to PEP 440).
 # - Before 1.0 we had the form "0.NNN".
-__version__ = "2.4.0"
+__version__ = "2.4.1"
 base_version = __version__
 
 mypy_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))


=====================================
mypyc/irbuild/env_class.py
=====================================
@@ -31,6 +31,7 @@ from mypyc.ir.rtypes import RInstance, bitmap_rprimitive, object_rprimitive
 from mypyc.irbuild.builder import IRBuilder, SymbolTarget
 from mypyc.irbuild.context import FuncInfo, GeneratorClass, ImplicitClass
 from mypyc.irbuild.targets import AssignmentTargetAttr
+from mypyc.irbuild.util import get_func_target_symbol
 
 
 def setup_env_class(builder: IRBuilder) -> ClassIR:
@@ -141,7 +142,7 @@ def load_env_registers(builder: IRBuilder, prefix: str = "") -> None:
         # If this is a FuncDef, then make sure to load the FuncDef into its own environment
         # class so that the function can be called recursively.
         if isinstance(fitem, FuncDef) and fn_info.add_nested_funcs_to_env:
-            setup_func_for_recursive_call(builder, fitem, fn_info.callable_class, prefix=prefix)
+            setup_func_for_recursive_call(builder, fitem, fn_info.callable_class)
 
 
 def load_outer_env(
@@ -298,8 +299,13 @@ def add_vars_to_env(builder: IRBuilder, prefix: str = "") -> None:
                 )
 
     if fn_info.fitem in builder.encapsulating_funcs:
+        added: set[SymbolNode] = set()
         for nested_fn in builder.encapsulating_funcs[fn_info.fitem]:
             if isinstance(nested_fn, FuncDef):
+                target_symbol = get_func_target_symbol(nested_fn)
+                if target_symbol in added:
+                    continue
+                added.add(target_symbol)
                 # The return type is 'object' instead of an RInstance of the
                 # callable class because differently defined functions with
                 # the same name and signature across conditional blocks
@@ -308,10 +314,10 @@ def add_vars_to_env(builder: IRBuilder, prefix: str = "") -> None:
                 nested_prefix = prefix
                 if nested_fn.is_generator or nested_fn.is_coroutine:
                     nested_prefix = GENERATOR_ATTRIBUTE_PREFIX
-                keep_alive = is_free_variable(builder, nested_fn)
-                if fn_info.is_generator and not builder.is_captured_by_nested_func(nested_fn):
+                keep_alive = is_free_variable(builder, target_symbol)
+                if fn_info.is_generator and not builder.is_captured_by_nested_func(target_symbol):
                     builder.add_var_to_generator_frame(
-                        nested_fn,
+                        target_symbol,
                         object_rprimitive,
                         fn_info.generator_class.self_reg,
                         reassign=False,
@@ -319,7 +325,7 @@ def add_vars_to_env(builder: IRBuilder, prefix: str = "") -> None:
                     )
                 else:
                     builder.add_var_to_env_class(
-                        nested_fn,
+                        target_symbol,
                         object_rprimitive,
                         env_for_func,
                         reassign=False,
@@ -328,9 +334,7 @@ def add_vars_to_env(builder: IRBuilder, prefix: str = "") -> None:
                     )
 
 
-def setup_func_for_recursive_call(
-    builder: IRBuilder, fdef: FuncDef, base: ImplicitClass, prefix: str = ""
-) -> None:
+def setup_func_for_recursive_call(builder: IRBuilder, fdef: FuncDef, base: ImplicitClass) -> None:
     """Enable calling a nested function (with a callable class) recursively.
 
     Adds the instance of the callable class representing the given
@@ -338,10 +342,18 @@ def setup_func_for_recursive_call(
     be called recursively. Note that this needs to be done only for
     nested functions.
     """
-    # First, set the attribute of the environment class so that GetAttr can be called on it.
     prev_env = builder.fn_infos[-2].env_class
-    attr_name = prefix + fdef.name
-    prev_env.attributes[attr_name] = builder.type_to_rtype(fdef.type)
+    target_symbol = get_func_target_symbol(fdef)
+    target = builder.symtables[-2].get(target_symbol)
+    if (
+        not isinstance(target_symbol, FuncDef)
+        or not isinstance(target, AssignmentTargetAttr)
+        or not isinstance(target.obj.type, RInstance)
+        or target.obj.type.class_ir is not prev_env
+    ):
+        return
+
+    attr_name = target.attr
     line = fdef.line
 
     if isinstance(base, GeneratorClass):
@@ -355,7 +367,7 @@ def setup_func_for_recursive_call(
     # Obtain the instance of the callable class representing the FuncDef, and add it to the
     # current environment.
     val = builder.add(GetAttr(prev_env_reg, attr_name, line))
-    target = builder.add_local_reg(fdef, object_rprimitive)
+    target = builder.add_local_reg(target_symbol, object_rprimitive)
     builder.assign(target, val, line)
 
 


=====================================
mypyc/irbuild/function.py
=====================================
@@ -77,6 +77,7 @@ from mypyc.irbuild.env_class import (
 )
 from mypyc.irbuild.generator import gen_generator_func, gen_generator_func_body
 from mypyc.irbuild.targets import AssignmentTarget
+from mypyc.irbuild.util import get_func_target_symbol
 from mypyc.primitives.dict_ops import (
     dict_get_method_with_none,
     dict_new_op,
@@ -925,11 +926,10 @@ def get_func_target(builder: IRBuilder, fdef: FuncDef) -> AssignmentTarget:
     If the function was not already defined somewhere, then define it
     and add it to the current environment.
     """
-    if orig := fdef.original_def:
-        if isinstance(orig, Decorator):
-            orig = orig.func
+    target_symbol = get_func_target_symbol(fdef)
+    if target_symbol is not fdef:
         # Get the target associated with the previously defined FuncDef.
-        return builder.lookup(orig)
+        return builder.lookup(target_symbol)
 
     if builder.fn_info.is_generator or builder.fn_info.add_nested_funcs_to_env:
         return builder.lookup(fdef)


=====================================
mypyc/irbuild/generator.py
=====================================
@@ -111,9 +111,7 @@ def gen_generator_func_body(builder: IRBuilder, fn_info: FuncInfo, func_reg: Val
         and top_level
         and top_level.add_nested_funcs_to_env
     ):
-        setup_func_for_recursive_call(
-            builder, fitem, builder.fn_info.generator_class, prefix=GENERATOR_ATTRIBUTE_PREFIX
-        )
+        setup_func_for_recursive_call(builder, fitem, builder.fn_info.generator_class)
     cleanup_on_error = BasicBlock()
     builder.builder.push_error_handler(cleanup_on_error)
     create_switch_for_generator_class(builder)


=====================================
mypyc/irbuild/util.py
=====================================
@@ -346,6 +346,14 @@ def get_func_def(op: FuncDef | Decorator | OverloadedFuncDef) -> FuncDef:
     return op
 
 
+def get_func_target_symbol(fdef: FuncDef) -> FuncDef | Var:
+    """Return the symbol used to store a possibly redefined function."""
+    original = fdef.original_def
+    if isinstance(original, Decorator):
+        return original.func
+    return original or fdef
+
+
 def concrete_arg_kind(kind: ArgKind) -> ArgKind:
     """Find the concrete version of an arg kind that is being passed."""
     if kind == ARG_OPT:


=====================================
mypyc/test-data/run-functions.test
=====================================
@@ -1399,6 +1399,33 @@ print(f(1))
 [out]
 2
 
+[case testReassignedNestedFunction]
+from typing import Callable, Generator
+
+def outer(flag: bool) -> list[int]:
+    out: list[int] = []
+    f: Callable[[int], None] = lambda n: out.append(-1)
+
+    def swap() -> None:
+        nonlocal f
+        f = lambda n: out.append(100 + n)
+
+    if flag:
+        def f(n: int) -> None:
+            def k(m: int) -> int:
+                return k(m - 1) if m else 0
+
+            out.append(n + k(2))
+            if n == 0:
+                swap()
+                f(1)   # should call the lambda installed by swap()
+    f(0)
+    return out
+
+def test_reassigned_nested_function() -> None:
+    assert outer(False) == [-1]
+    assert outer(True) == [0, 101]
+
 [case testStarArgFastPaths]
 from typing import Any, Mapping
 def fn(x: str, y: int) -> str:


=====================================
mypyc/test-data/run-generators.test
=====================================
@@ -825,6 +825,38 @@ def test_nested_generator_private_spill() -> None:
     assert yields == ("right",)
     assert value == "capturedleftsent"
 
+[case testNestedGeneratorPrivateHelper]
+from typing import Iterator
+
+def outer() -> Iterator[int]:
+    def captured() -> Iterator[int]:
+        yield 1
+
+    def private() -> Iterator[int]:
+        yield from captured()
+
+    yield from private()
+
+def test_nested_generator_private_helper() -> None:
+    assert list(outer()) == [1]
+
+[case testRedefinedNestedGeneratorHelper]
+from typing import Iterator
+
+def redefined_nested_helper(flag: bool) -> Iterator[int]:
+    if flag:
+        def helper(n: int) -> int:
+            return 1
+    else:
+        def helper(n: int) -> int:
+            return helper(1) if not n else 2
+
+    yield helper(0)
+
+def test_redefined_nested_generator_helper() -> None:
+    assert list(redefined_nested_helper(True)) == [1]
+    assert list(redefined_nested_helper(False)) == [2]
+
 [case testGeneratorPrivateAndEscapedBindings]
 from typing import Any, Callable, Generator, Iterator
 


=====================================
mypyc/test/test_generator_spills.py
=====================================
@@ -184,6 +184,56 @@ def gen() -> Iterator[Any]:
         )
         assert environment is not frame
 
+    def test_nested_generator_private_helper_stays_on_frame(self) -> None:
+        module, _, _, _ = build_ir_for_single_file2("""\
+from typing import Iterator
+
+def outer() -> Iterator[int]:
+    def captured() -> Iterator[int]:
+        yield 1
+    def private() -> Iterator[int]:
+        yield from captured()
+    yield from private()
+""".splitlines())
+        outer_frame = next(cl for cl in module.classes if cl.name == "outer_gen")
+        environment_type = outer_frame.attributes[ENV_ATTR_NAME]
+        assert isinstance(environment_type, RInstance)
+        environment = environment_type.class_ir
+
+        assert GENERATOR_ATTRIBUTE_PREFIX + "captured" in environment.attributes
+        assert "private" in frame_variables(outer_frame)
+        assert GENERATOR_ATTRIBUTE_PREFIX + "private" not in environment.attributes
+
+        private_frame = next(cl for cl in module.classes if cl.name.startswith("private_gen___"))
+        private_helper = private_frame.env_user_function
+        assert private_helper is not None
+        assert not any(
+            isinstance(op, GetAttr) and op.attr == GENERATOR_ATTRIBUTE_PREFIX + "private"
+            for block in private_helper.blocks
+            for op in block.ops
+        )
+
+    def test_redefined_nested_helper_has_single_storage_location(self) -> None:
+        module, _, _, _ = build_ir_for_single_file2("""\
+from typing import Iterator
+
+def outer(flag: bool) -> Iterator[int]:
+    if flag:
+        def helper(n: int) -> int:
+            return 1
+    else:
+        def helper(n: int) -> int:
+            return helper(1) if not n else 2
+    yield helper(0)
+""".splitlines())
+        outer_frame = next(cl for cl in module.classes if cl.name == "outer_gen")
+        environment_type = outer_frame.attributes[ENV_ATTR_NAME]
+        assert isinstance(environment_type, RInstance)
+        environment = environment_type.class_ir
+
+        assert GENERATOR_ATTRIBUTE_PREFIX + "helper" in environment.attributes
+        assert "helper" not in frame_variables(outer_frame)
+
     def test_nested_finally_promotes_each_saved_exception(self) -> None:
         cl = generator_class(
             """\


=====================================
pyproject.toml
=====================================
@@ -15,7 +15,7 @@ requires = [
     "types-psutil",
     "types-setuptools",
     # required to work around a mypyc import bug
-    "ast-serialize>=0.11.2,<1.0.0",
+    "ast-serialize>=0.12.1,<1.0.0",
 ]
 build-backend = "setuptools.build_meta"
 
@@ -59,7 +59,7 @@ dependencies = [
   "pathspec>=1.0.0",
   "tomli>=1.1.0; python_version<'3.11'",
   "librt>=0.16.0; platform_python_implementation != 'PyPy'",
-  "ast-serialize>=0.11.2,<1.0.0",
+  "ast-serialize>=0.12.1,<1.0.0",
 ]
 dynamic = ["version"]
 


=====================================
test-data/unit/check-classes.test
=====================================
@@ -9741,3 +9741,16 @@ class C:
 
 reveal_type(C.x)  # N: Revealed type is "builtins.int | None"
 [builtins fixtures/classmethod.pyi]
+
+[case testSettablePropertyGetterCheckedWhenPartOfInterface]
+class A:
+    @property
+    def p(self) -> str:
+        def nested() -> int:
+            return "no"  # E: Incompatible return value type (got "str", expected "int")
+        return 0  # E: Incompatible return value type (got "int", expected "str")
+
+    @p.setter
+    def p(self, value: int) -> None:
+        self.x = value
+[builtins fixtures/property.pyi]


=====================================
test-data/unit/check-errorcodes.test
=====================================
@@ -848,7 +848,7 @@ main:1: error: Name "y" is not defined  [name-defined]
 main:2: error: Name "ignored" is not defined  [name-defined]
 main:2: error: Name "y" is not defined  [name-defined]
 
-[case testErrorCodeTypeIgnoreMisspelled2]
+[case testErrorCodeTypeIgnoreMisspelled2-skip]
 x = y  # type: int  # type: ignored[foo]
 x = y  # type: int  # type: ignored [foo]
 [out]


=====================================
test-data/unit/native-parser.test
=====================================
@@ -3116,3 +3116,13 @@ MypyFile:1(
             Args(
               NameExpr(x)
               StrExpr())))))))
+
+[case testNoneInStringType]
+x: "None"
+[out]
+MypyFile:1(
+  AssignmentStmt:1(
+    NameExpr(x)
+    TempNode:1(
+      Any)
+    None?))


=====================================
test-requirements.txt
=====================================
@@ -4,7 +4,7 @@
 #
 #    pip-compile --allow-unsafe --output-file=test-requirements.txt --strip-extras test-requirements.in
 #
-ast-serialize==0.11.2
+ast-serialize==0.12.1
     # via -r mypy-requirements.txt
 attrs==26.1.0
     # via -r test-requirements.in



View it on GitLab: https://salsa.debian.org/python-team/packages/mypy/-/compare/d2c5b436f276c9658227ecace331e33e731d0d5d...c0555920cf51780f78275573dd7f5b4144fefd36

-- 
View it on GitLab: https://salsa.debian.org/python-team/packages/mypy/-/compare/d2c5b436f276c9658227ecace331e33e731d0d5d...c0555920cf51780f78275573dd7f5b4144fefd36
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20261029/85f934b9/attachment-0001.htm>


More information about the debian-med-commit mailing list