From: Mike Bayer Date: Fri, 11 Nov 2022 21:04:06 +0000 (-0500) Subject: backport relevant mypy 0.990 fixes from main X-Git-Tag: rel_1_4_44~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=910504b67c22bfc767e2e47e284b792653efdefc;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git backport relevant mypy 0.990 fixes from main Changes from ebb54e80a5a52d0cce4cba1abc21c707a42c2c73 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 --- diff --git a/doc/build/changelog/unreleased_14/mypy_fixes.rst b/doc/build/changelog/unreleased_14/mypy_fixes.rst new file mode 100644 index 0000000000..32e4f14658 --- /dev/null +++ b/doc/build/changelog/unreleased_14/mypy_fixes.rst @@ -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. diff --git a/test/ext/mypy/test_mypy_plugin_py3k.py b/test/ext/mypy/test_mypy_plugin_py3k.py index 181a7958f3..3df758c56d 100644 --- a/test/ext/mypy/test_mypy_plugin_py3k.py +++ b/test/ext/mypy/test_mypy_plugin_py3k.py @@ -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])