From 63453365f5f1107fa28ef69b7d3846415241192e Mon Sep 17 00:00:00 2001 From: Andrey Bienkowski Date: Thu, 4 Mar 2021 08:04:01 +0300 Subject: [PATCH] Workaround mypy AssertionError sometimes mypy was failing with: ``` AssertionError: Cannot find component '_Result@144' for 'tests.util.test_pep517._Result@144' ``` This is due to a bug: https://github.com/python/mypy/issues/7281 I have applied the workaround suggested in the above issue Full traceback ``` type run-test: commands[1] | mypy tests Traceback (most recent call last): File "/home/user/tox/.tox/type/bin/mypy", line 8, in sys.exit(console_entry()) File "/home/user/tox/.tox/type/lib/python3.9/site-packages/mypy/__main__.py", line 11, in console_entry main(None, sys.stdout, sys.stderr) File "mypy/main.py", line 90, in main File "mypy/build.py", line 179, in build File "mypy/build.py", line 253, in _build File "mypy/build.py", line 2638, in dispatch File "mypy/build.py", line 2955, in process_graph File "mypy/build.py", line 3033, in process_fresh_modules File "mypy/build.py", line 1977, in fix_cross_refs File "mypy/fixup.py", line 26, in fixup_module File "mypy/fixup.py", line 77, in visit_symbol_table File "mypy/fixup.py", line 301, in lookup_qualified_stnode File "mypy/lookup.py", line 47, in lookup_fully_qualified AssertionError: Cannot find component '_Result@144' for 'tests.util.test_pep517._Result@144' ERROR: InvocationError for command /home/user/tox/.tox/type/bin/mypy tests (exited with code 1) ``` --- tests/util/test_pep517.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/util/test_pep517.py b/tests/util/test_pep517.py index 5f7adb2fd..4cf8cc2c1 100644 --- a/tests/util/test_pep517.py +++ b/tests/util/test_pep517.py @@ -140,10 +140,11 @@ def test_pep517_bad_message(frontend_setuptools: SubprocessFrontend, tmp_path: P assert "Backend: incorrect request to backend: bytearray(b'{{')" in err -def test_pep517_result_missing(frontend_setuptools: SubprocessFrontend, tmp_path: Path, mocker: MockerFixture) -> None: - class _Result(NamedTuple): - name: str +class _Result(NamedTuple): + name: str + +def test_pep517_result_missing(frontend_setuptools: SubprocessFrontend, tmp_path: Path, mocker: MockerFixture) -> None: @contextmanager def named_temporary_file(prefix: str) -> Iterator[_Result]: write = S_IWUSR | S_IWGRP | S_IWOTH