backport relevant mypy 0.990 fixes from main

Changes from ebb54e80a5
which are relevant here.

Adjusted the test suite which tests the Mypy plugin to accommodate for
changes in Mypy 0.990 regarding how it handles message output, which affect
how sys.path is interpreted when determining if notes and errors should be
printed for particular files. The change broke the test suite as the files
within the test directory itself no longer produced messaging when run
under the mypy API.

Change-Id: I1728fd3bd21a4d499db0a4939ee27c67b2c34123
This commit is contained in:
Mike Bayer
2022-11-11 16:04:06 -05:00
parent c4f3a72cf5
commit 910504b67c
2 changed files with 24 additions and 2 deletions
+9
View File
@@ -0,0 +1,9 @@
.. change::
:tags: bug, tests
Adjusted the test suite which tests the Mypy plugin to accommodate for
changes in Mypy 0.990 regarding how it handles message output, which affect
how sys.path is interpreted when determining if notes and errors should be
printed for particular files. The change broke the test suite as the files
within the test directory itself no longer produced messaging when run
under the mypy API.
+15 -2
View File
@@ -63,7 +63,18 @@ class MypyPluginTest(fixtures.TestBase):
),
]
args.append(path)
if incremental:
args.append(path)
else:
# mypy as of 0.990 is more aggressively blocking messaging
# for paths that are in sys.path, and as pytest puts currdir,
# test/ etc in sys.path, just copy the source file to the
# tempdir we are working in so that we don't have to try to
# manipulate sys.path and/or guess what mypy is doing
filename = os.path.basename(path)
test_program = os.path.join(cachedir, filename)
shutil.copyfile(path, test_program)
args.append(test_program)
result = api.run(args)
return result
@@ -185,7 +196,9 @@ class MypyPluginTest(fixtures.TestBase):
not_located = []
if expected_errors:
eq_(result[2], 1, msg=result)
# mypy 0.990 changed how return codes work, so don't assume a
# 1 or a 0 return code here, could be either depending on if
# errors were generated or not
print(result[0])