From fd23ee145b87a7caa19ea7dc4a542bebf20f6216ac75c19c922cb49b4ca6a38d Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Thu, 4 Apr 2024 04:59:52 +0000 Subject: [PATCH] - Add patch workaround-parenthesized-context-managers.patch: * Work around parenthesized context managers issue. - Stop skipping tests that are now fixed. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-mypy?expand=0&rev=13 --- python-mypy.changes | 7 + python-mypy.spec | 12 +- ...round-parenthesized-context-managers.patch | 131 ++++++++++++++++++ 3 files changed, 143 insertions(+), 7 deletions(-) create mode 100644 workaround-parenthesized-context-managers.patch diff --git a/python-mypy.changes b/python-mypy.changes index 4cd4d6b..af95604 100644 --- a/python-mypy.changes +++ b/python-mypy.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu Apr 4 04:58:56 UTC 2024 - Steve Kowalik + +- Add patch workaround-parenthesized-context-managers.patch: + * Work around parenthesized context managers issue. +- Stop skipping tests that are now fixed. + ------------------------------------------------------------------- Wed Mar 27 15:59:56 UTC 2024 - ecsos diff --git a/python-mypy.spec b/python-mypy.spec index 88f412c..97e5f08 100644 --- a/python-mypy.spec +++ b/python-mypy.spec @@ -35,6 +35,8 @@ Source2: https://files.pythonhosted.org/packages/source/t/types-psutil/ty # License Source3: Apache-2.0. Only for the test suite, not packaged here. Source3: https://files.pythonhosted.org/packages/source/t/types-setuptools/types-setuptools-%{types_setuptools_version}.tar.gz Source99: python-mypy-rpmlintrc +# PATCH-FIX-UPSTREAM gh#python/mypy#16949 +Patch0: workaround-parenthesized-context-managers.patch BuildRequires: %{python_module exceptiongroup} BuildRequires: %{python_module mypy_extensions >= 1.0.0} BuildRequires: %{python_module pip} @@ -51,7 +53,7 @@ Requires: python-typing_extensions >= 3.10 Requires: (python-tomli >= 1.1.0 if python-base < 3.11) Requires: (python-typed-ast >= 1.4.0 if python-base < 3.8) Requires(post): update-alternatives -Requires(postun):update-alternatives +Requires(postun): update-alternatives %if "%{python_flavor}" == "python3" || "%{?python_provides}" == "python3" Provides: mypy = %{version} Obsoletes: mypy < %{version} @@ -138,17 +140,13 @@ export MYPYC_OPT_LEVEL=2 if [ $(getconf LONG_BIT) -ne 64 ]; then # gh#python/mypy#11148 donttest+=" or testSubclassSpecialize or testMultiModuleSpecialize" - # fails only in python36 (EOL) - python36_donttest+=" or testIntOps" fi # the fake test_module is not in the modulepath without pytest-xdist # or with pytest-xdist >= 2.3 -- https://github.com/python/mypy/issues/11019 donttest+=" or teststubtest" -# gh#python/mypy#15221 -donttest+=" or testMathOps or testFloatOps" # fails on Python 3.11.4, see gh#python/mypy#15446. Patch db5b5af1201fff03465b0684d16b6489a62a3d78 does not apply clean, better wait for a new upstream version donttest+=" or PEP561Suite" -%pytest -n auto -k "not (testallexcept ${donttest} ${$python_donttest})" -x +%pytest -n auto -k "not (testallexcept ${donttest})" -x %endif %post @@ -162,7 +160,7 @@ donttest+=" or PEP561Suite" %license LICENSE %{python_sitelib}/mypy %{python_sitelib}/mypyc -%{python_sitelib}/mypy-%{version}*-info +%{python_sitelib}/mypy-%{version}.dist-info %python_alternative %{_bindir}/dmypy %python_alternative %{_bindir}/mypy %python_alternative %{_bindir}/mypyc diff --git a/workaround-parenthesized-context-managers.patch b/workaround-parenthesized-context-managers.patch new file mode 100644 index 0000000..bd9fdc9 --- /dev/null +++ b/workaround-parenthesized-context-managers.patch @@ -0,0 +1,131 @@ +From fb610cb043ea990046d3665ac39238d5223e3eb3 Mon Sep 17 00:00:00 2001 +From: hauntsaninja +Date: Sun, 25 Feb 2024 14:01:07 -0800 +Subject: [PATCH 1/4] Workaround parenthesised context manager issue + +Fixes #16945 +--- + mypy/checker.py | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/mypy/checker.py b/mypy/checker.py +index 56be3db3f9e7..5081265c9cac 100644 +--- a/mypy/checker.py ++++ b/mypy/checker.py +@@ -526,16 +526,18 @@ def check_second_pass( + # print("XXX in pass %d, class %s, function %s" % + # (self.pass_num, type_name, node.fullname or node.name)) + done.add(node) +- with ( ++ tscope_class_ctx = ( + self.tscope.class_scope(active_typeinfo) + if active_typeinfo + else nullcontext() +- ): +- with ( ++ ) ++ with tscope_class_ctx: ++ checker_scope_class_ctx = ( + self.scope.push_class(active_typeinfo) + if active_typeinfo + else nullcontext() +- ): ++ ) ++ with checker_scope_class_ctx: + self.check_partial(node) + return True + + +From 4c9d637919ef5262b94d6dc160f63d12bd126167 Mon Sep 17 00:00:00 2001 +From: hauntsaninja +Date: Sun, 25 Feb 2024 14:14:56 -0800 +Subject: [PATCH 2/4] . + +--- + mypy/checker.py | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/mypy/checker.py b/mypy/checker.py +index 5081265c9cac..426e5a805893 100644 +--- a/mypy/checker.py ++++ b/mypy/checker.py +@@ -526,6 +526,7 @@ def check_second_pass( + # print("XXX in pass %d, class %s, function %s" % + # (self.pass_num, type_name, node.fullname or node.name)) + done.add(node) ++ # Alias context managers to work around https://github.com/python/cpython/issues/115881 + tscope_class_ctx = ( + self.tscope.class_scope(active_typeinfo) + if active_typeinfo + +From 9e33616ec8405b4e3c3b345c8461e77c4786a22c Mon Sep 17 00:00:00 2001 +From: hauntsaninja +Date: Sun, 25 Feb 2024 14:18:34 -0800 +Subject: [PATCH 3/4] . + +--- + mypy/checker.py | 21 ++++++--------------- + 1 file changed, 6 insertions(+), 15 deletions(-) + +diff --git a/mypy/checker.py b/mypy/checker.py +index 426e5a805893..d60f223036ea 100644 +--- a/mypy/checker.py ++++ b/mypy/checker.py +@@ -4,7 +4,7 @@ + + import itertools + from collections import defaultdict +-from contextlib import contextmanager, nullcontext ++from contextlib import contextmanager, ExitStack + from typing import ( + AbstractSet, + Callable, +@@ -526,20 +526,11 @@ def check_second_pass( + # print("XXX in pass %d, class %s, function %s" % + # (self.pass_num, type_name, node.fullname or node.name)) + done.add(node) +- # Alias context managers to work around https://github.com/python/cpython/issues/115881 +- tscope_class_ctx = ( +- self.tscope.class_scope(active_typeinfo) +- if active_typeinfo +- else nullcontext() +- ) +- with tscope_class_ctx: +- checker_scope_class_ctx = ( +- self.scope.push_class(active_typeinfo) +- if active_typeinfo +- else nullcontext() +- ) +- with checker_scope_class_ctx: +- self.check_partial(node) ++ with ExitStack() as stack: ++ if active_typeinfo: ++ stack.enter_context(self.tscope.class_scope(active_typeinfo)) ++ stack.enter_context(self.scope.push_class(active_typeinfo)) ++ self.check_partial(node) + return True + + def check_partial(self, node: DeferredNodeType | FineGrainedDeferredNodeType) -> None: + +From f7f9f114451065a27a7d0d734ea38f1b80a965df Mon Sep 17 00:00:00 2001 +From: hauntsaninja +Date: Sun, 25 Feb 2024 14:18:46 -0800 +Subject: [PATCH 4/4] . + +--- + mypy/checker.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/mypy/checker.py b/mypy/checker.py +index d60f223036ea..9f987cb5ccdf 100644 +--- a/mypy/checker.py ++++ b/mypy/checker.py +@@ -4,7 +4,7 @@ + + import itertools + from collections import defaultdict +-from contextlib import contextmanager, ExitStack ++from contextlib import ExitStack, contextmanager + from typing import ( + AbstractSet, + Callable,