commit:     43e7824af28e565bef9186901bd015049aa7261a
Author:     Louis Sautier <sbraz <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 18 17:38:03 2020 +0000
Commit:     Louis Sautier <sbraz <AT> gentoo <DOT> org>
CommitDate: Wed Nov 18 17:42:27 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=43e7824a

dev-python/mypy: bump to 0.790

Closes: https://bugs.gentoo.org/754846
Package-Manager: Portage-3.0.8, Repoman-3.0.2
Signed-off-by: Louis Sautier <sbraz <AT> gentoo.org>

 dev-python/mypy/Manifest                          |   2 +
 dev-python/mypy/files/mypy-0.790-py39-fixes.patch | 161 ++++++++++++++++++++++
 dev-python/mypy/mypy-0.790.ebuild                 |  76 ++++++++++
 3 files changed, 239 insertions(+)

diff --git a/dev-python/mypy/Manifest b/dev-python/mypy/Manifest
index c589ce5c1b6..75ba045782b 100644
--- a/dev-python/mypy/Manifest
+++ b/dev-python/mypy/Manifest
@@ -1 +1,3 @@
 DIST mypy-0.782.tar.gz 2529814 BLAKE2B 
c75771fb40524c2c8675236eaaddd6e39d13b4fd4f6f15f279b2e0be75eb0630987cb90f31bd7c65c4a322de4915d3a260e8f6f375b49157fea4b6362316f333
 SHA512 
f94433f79ea76b53ebb70589ca04ba3f39847050f73cf6deac00a3db13d742613a8ecb1a11fb84a878458025c6776b236b074e93e577c1b597e31d1300974767
+DIST mypy-0.790.tar.gz 2082487 BLAKE2B 
f8efcb701b4b7533306948721968c9a01ab6c6e56ec99fe6c36e35aca50b52f29f518aee2268a628539a372b8024094ef2d4d87da580b4dd667f41133351596e
 SHA512 
be670456bb64cd197bb6a73832b7e0fd6439ae4af128212328a41cd93d9f644a82e79ffb05bf4695e99bd9788244a24916bf765cf30a6f162cf3b471f45c25b8
+DIST mypy-typeshed-5be9c91.tar.gz 583006 BLAKE2B 
08ab2b6d479ccc66493524482051e825c65c0a94ea5cac8e56a8ea1dca85eda6104e4ed3188b7d5ce1ea99058019d66a21a7e270e3ad9df694be67ea1e6a7ce9
 SHA512 
2912bcf66e0f550941eb9c1f34979644857448a4bec478cfc0d662e9a401ade93ccfb2f57b5348504b4d6f0f23e576da609167f1ec3a0861414fc9c7dea80243

diff --git a/dev-python/mypy/files/mypy-0.790-py39-fixes.patch 
b/dev-python/mypy/files/mypy-0.790-py39-fixes.patch
new file mode 100644
index 00000000000..a7a581ea896
--- /dev/null
+++ b/dev-python/mypy/files/mypy-0.790-py39-fixes.patch
@@ -0,0 +1,161 @@
+From 13ae58ffe8bedb7da9f4c657297f0d61e681d671 Mon Sep 17 00:00:00 2001
+From: Shantanu <12621235+hauntsani...@users.noreply.github.com>
+Date: Sun, 30 Aug 2020 18:11:57 -0700
+Subject: [PATCH] mypy: get CI green for py39 (#9376)
+
+Due to Python 3.9's new parser, this has a different (and better) error
+message on Python 3.9.
+
+This is effectively a test of typed_ast / ast, so I don't think it
+matters too much. I'm happy to alternatively just get rid of the test
+altogether, or if people feel strongly, come up with a way to run the
+test when run with older Pythons.
+
+Co-authored-by: hauntsaninja <>
+---
+ .travis.yml                        | 3 ---
+ mypy/test/testcheck.py             | 2 ++
+ test-data/unit/check-kwargs.test   | 7 -------
+ test-data/unit/check-python39.test | 9 +++++++++
+ 4 files changed, 11 insertions(+), 10 deletions(-)
+ create mode 100644 test-data/unit/check-python39.test
+
+diff --git a/mypy/test/testcheck.py b/mypy/test/testcheck.py
+index 49a85861b6..39a35c7280 100644
+--- a/mypy/test/testcheck.py
++++ b/mypy/test/testcheck.py
+@@ -94,6 +94,8 @@
+ # Tests that use Python 3.8-only AST features (like expression-scoped 
ignores):
+ if sys.version_info >= (3, 8):
+     typecheck_files.append('check-python38.test')
++if sys.version_info >= (3, 9):
++    typecheck_files.append('check-python39.test')
+ 
+ # Special tests for platforms with case-insensitive filesystems.
+ if sys.platform in ('darwin', 'win32'):
+diff --git a/test-data/unit/check-kwargs.test 
b/test-data/unit/check-kwargs.test
+index 1dd450caae..a587be3e06 100644
+--- a/test-data/unit/check-kwargs.test
++++ b/test-data/unit/check-kwargs.test
+@@ -53,13 +53,6 @@ f(b=[], a=A())
+ class A: pass
+ [builtins fixtures/list.pyi]
+ 
+-[case testGivingSameKeywordArgumentTwice]
+-import typing
+-def f(a: 'A', b: 'B') -> None: pass
+-f(a=A(), b=B(), a=A()) # E: keyword argument repeated
+-class A: pass
+-class B: pass
+-
+ [case testGivingArgumentAsPositionalAndKeywordArg]
+ import typing
+ def f(a: 'A', b: 'B' = None) -> None: pass
+diff --git a/test-data/unit/check-python39.test 
b/test-data/unit/check-python39.test
+new file mode 100644
+index 0000000000..0e9ec683ae
+--- /dev/null
++++ b/test-data/unit/check-python39.test
+@@ -0,0 +1,9 @@
++[case testGivingSameKeywordArgumentTwice]
++# This test was originally in check-kwargs.test
++# Python 3.9's new parser started producing a different error message here. 
Since this isn't the
++# most important test, to deal with this we'll only run this test with Python 
3.9 and later.
++import typing
++def f(a: 'A', b: 'B') -> None: pass
++f(a=A(), b=B(), a=A()) # E: "f" gets multiple values for keyword argument "a"
++class A: pass
++class B: pass
+From ab1bd98cc8a6415398121a47c687ede6f4cca4fd Mon Sep 17 00:00:00 2001
+From: Shantanu <12621235+hauntsani...@users.noreply.github.com>
+Date: Thu, 8 Oct 2020 11:18:18 -0700
+Subject: [PATCH] py39: fix mypyc complaint (#9552)
+
+I was trying to build wheels for Python 3.9 as part of #9536, but ran
+into this issue. You'll notice a couple hundred lines up msullivan
+points out that mypyc can't handle conditional method definition, so
+that's not an option here.
+
+Co-authored-by: hauntsaninja <>
+---
+ mypy/fastparse.py | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/mypy/fastparse.py b/mypy/fastparse.py
+index 2dafbf4e14..0b72214100 100644
+--- a/mypy/fastparse.py
++++ b/mypy/fastparse.py
+@@ -1257,11 +1257,13 @@ def visit_Slice(self, n: ast3.Slice) -> SliceExpr:
+ 
+     # ExtSlice(slice* dims)
+     def visit_ExtSlice(self, n: ast3.ExtSlice) -> TupleExpr:
+-        return TupleExpr(self.translate_expr_list(n.dims))
++        # cast for mypyc's benefit on Python 3.9
++        return TupleExpr(self.translate_expr_list(cast(Any, n.dims)))
+ 
+     # Index(expr value)
+     def visit_Index(self, n: Index) -> Node:
+-        return self.visit(n.value)
++        # cast for mypyc's benefit on Python 3.9
++        return self.visit(cast(Any, n.value))
+ 
+ 
+ class TypeConverter:
+From ffed88fb95fcbfdd1363f0f719bd3e13f8fe20e9 Mon Sep 17 00:00:00 2001
+From: Shantanu <12621235+hauntsani...@users.noreply.github.com>
+Date: Thu, 8 Oct 2020 15:00:42 -0700
+Subject: [PATCH] py39: fix mypyc complaints part 2 (#9562)
+
+Necessary because I previously didn't actually fix mypyc's complaint +
+mypyc has more complaints.
+The sys.version_info aliasing works around us hitting
+https://github.com/python/mypy/blob/08f207ef4a09f56d710d63775771ae921c41d4bc/mypyc/irbuild/expression.py#L44
+
+Co-authored-by: hauntsaninja <>
+---
+ mypy/fastparse.py | 12 ++++++++----
+ 1 file changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/mypy/fastparse.py b/mypy/fastparse.py
+index 0b72214100..3319cd6489 100644
+--- a/mypy/fastparse.py
++++ b/mypy/fastparse.py
+@@ -169,7 +169,9 @@ def parse(source: Union[str, bytes],
+         tree.path = fnam
+         tree.is_stub = is_stub_file
+     except SyntaxError as e:
+-        if sys.version_info < (3, 9) and e.filename == "<fstring>":
++        # alias to please mypyc
++        is_py38_or_earlier = sys.version_info < (3, 9)
++        if is_py38_or_earlier and e.filename == "<fstring>":
+             # In Python 3.8 and earlier, syntax errors in f-strings have 
lineno relative to the
+             # start of the f-string. This would be misleading, as mypy will 
report the error as the
+             # lineno within the file.
+@@ -1210,9 +1212,11 @@ def visit_Attribute(self, n: Attribute) -> 
Union[MemberExpr, SuperExpr]:
+     def visit_Subscript(self, n: ast3.Subscript) -> IndexExpr:
+         e = IndexExpr(self.visit(n.value), self.visit(n.slice))
+         self.set_line(e, n)
++        # alias to please mypyc
++        is_py38_or_earlier = sys.version_info < (3, 9)
+         if (
+             isinstance(n.slice, ast3.Slice) or
+-            (sys.version_info < (3, 9) and isinstance(n.slice, ast3.ExtSlice))
++            (is_py38_or_earlier and isinstance(n.slice, ast3.ExtSlice))
+         ):
+             # Before Python 3.9, Slice has no line/column in the raw ast. To 
avoid incompatibility
+             # visit_Slice doesn't set_line, even in Python 3.9 on.
+@@ -1258,12 +1262,12 @@ def visit_Slice(self, n: ast3.Slice) -> SliceExpr:
+     # ExtSlice(slice* dims)
+     def visit_ExtSlice(self, n: ast3.ExtSlice) -> TupleExpr:
+         # cast for mypyc's benefit on Python 3.9
+-        return TupleExpr(self.translate_expr_list(cast(Any, n.dims)))
++        return TupleExpr(self.translate_expr_list(cast(Any, n).dims))
+ 
+     # Index(expr value)
+     def visit_Index(self, n: Index) -> Node:
+         # cast for mypyc's benefit on Python 3.9
+-        return self.visit(cast(Any, n.value))
++        return self.visit(cast(Any, n).value)
+ 
+ 
+ class TypeConverter:

diff --git a/dev-python/mypy/mypy-0.790.ebuild 
b/dev-python/mypy/mypy-0.790.ebuild
new file mode 100644
index 00000000000..f2b26d130ce
--- /dev/null
+++ b/dev-python/mypy/mypy-0.790.ebuild
@@ -0,0 +1,76 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PYTHON_COMPAT=( python3_{6..9} )
+DISTUTILS_USE_SETUPTOOLS=rdepend
+
+inherit distutils-r1
+
+DESCRIPTION="Optional static typing for Python"
+HOMEPAGE="http://www.mypy-lang.org/";
+# One module is missing from the PyPI tarball
+# https://github.com/python/mypy/pull/9587
+# conftest.py is missing at the moment
+# https://github.com/python/mypy/pull/9543
+TYPESHED_COMMIT="5be9c91"
+SRC_URI="
+       https://github.com/python/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz
+       https://api.github.com/repos/python/typeshed/tarball/${TYPESHED_COMMIT} 
-> mypy-typeshed-${TYPESHED_COMMIT}.tar.gz
+"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~amd64 ~arm64 ~ia64 ~x86"
+
+# stubgen collides with this package: https://bugs.gentoo.org/585594
+RDEPEND="
+       !dev-util/stubgen
+       >=dev-python/psutil-4[${PYTHON_USEDEP}]
+       >=dev-python/typed-ast-1.4.0[${PYTHON_USEDEP}]
+       <dev-python/typed-ast-1.5.0[${PYTHON_USEDEP}]
+       >=dev-python/typing-extensions-3.7.4[${PYTHON_USEDEP}]
+       >=dev-python/mypy_extensions-0.4.3[${PYTHON_USEDEP}]
+       <dev-python/mypy_extensions-0.5.0[${PYTHON_USEDEP}]
+"
+BDEPEND="
+       test? (
+               >=dev-python/attrs-18.0[${PYTHON_USEDEP}]
+               >=dev-python/lxml-4.4.0[${PYTHON_USEDEP}]
+               >=dev-python/pytest-6.0.0[${PYTHON_USEDEP}]
+               >=dev-python/pytest-xdist-1.18[${PYTHON_USEDEP}]
+               >=dev-python/py-1.5.2[${PYTHON_USEDEP}]
+               >=dev-python/virtualenv-16.0.0[${PYTHON_USEDEP}]
+       )
+"
+
+PATCHES=(
+       # 
https://github.com/python/mypy/commit/13ae58ffe8bedb7da9f4c657297f0d61e681d671
+       # 
https://github.com/python/mypy/commit/ab1bd98cc8a6415398121a47c687ede6f4cca4fd
+       # 
https://github.com/python/mypy/commit/ffed88fb95fcbfdd1363f0f719bd3e13f8fe20e9
+       "${FILESDIR}/${P}-py39-fixes.patch"
+)
+
+distutils_enable_sphinx docs/source dev-python/sphinx_rtd_theme
+distutils_enable_tests pytest
+
+src_unpack() {
+       unpack ${A}
+       rmdir "${S}/mypy/typeshed" || die
+       mv "${WORKDIR}/python-typeshed-${TYPESHED_COMMIT}" "${S}/mypy/typeshed"
+}
+
+python_prepare_all() {
+       # 
https://github.com/python/mypy/commit/2f291f2e312dd3bf2c05c45da0b032b240bfd7ab
+       # Avoid a big patch by deleting the file manually
+       rm test-data/samples/crawl.py || die
+       distutils-r1_python_prepare_all
+}
+
+python_test() {
+       # Some mypy/test/testcmdline.py::PythonCmdlineSuite tests
+       # fail with high COLUMNS values
+       local -x COLUMNS=80
+       pytest -vv || die "Tests fail with ${EPYTHON}"
+}

Reply via email to