]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
backport relevant mypy 0.990 fixes from main
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 11 Nov 2022 21:04:06 +0000 (16:04 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 11 Nov 2022 21:17:03 +0000 (16:17 -0500)
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

doc/build/changelog/unreleased_14/mypy_fixes.rst [new file with mode: 0644]
test/ext/mypy/test_mypy_plugin_py3k.py

diff --git a/doc/build/changelog/unreleased_14/mypy_fixes.rst b/doc/build/changelog/unreleased_14/mypy_fixes.rst
new file mode 100644 (file)
index 0000000..32e4f14
--- /dev/null
@@ -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.
index 181a7958f3f3640930fa2fbc76f78b047272940f..3df758c56db1097a2f70716d631c9b2cb2cfe185 100644 (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])