]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
remove mypy_path workaround and ensure messages received
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 23 Jul 2022 14:18:06 +0000 (10:18 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 23 Jul 2022 16:16:27 +0000 (12:16 -0400)
Fixes: #8281
Change-Id: Ice47880ba7924daff68aef6b1791f3c66849f550

test/ext/mypy/plugin_files/relationship_err1.py
test/ext/mypy/plugin_files/relationship_err3.py
test/ext/mypy/plugin_files/typing_err3.py
test/ext/mypy/test_mypy_plugin_py3k.py

index ba3783f05a46ee7c91373d38aa4400a3018d3343..46e7067d340d8a6ef47c64c6e202cbaaa8d7a48d 100644 (file)
@@ -27,5 +27,4 @@ class A(Base):
     b_id: int = Column(ForeignKey("b.id"))
 
     # EXPECTED: Sending uselist=False and collection_class at the same time does not make sense # noqa
-    # EXPECTED_MYPY_RE: No overload variant of "relationship" matches argument types
     b: B = relationship(B, uselist=False, collection_class=set)
index aa76ae1f0e0cc749c1011dc63c577477011c3fe0..1c7cd9f303d48f3c01d5649891af0e2dce214732 100644 (file)
@@ -24,7 +24,7 @@ class A(Base):
 
     id = Column(Integer, primary_key=True)
     data = Column(String)
-    # EXPECTED: Left hand assignment 'bs: "Set[B]"' not compatible with ORM mapped expression of type "Mapped[List[B]]" # noqa
+
     bs: Set[B] = relationship(B, uselist=True, back_populates="a")
 
     # EXPECTED: Left hand assignment 'another_bs: "Set[B]"' not compatible with ORM mapped expression of type "Mapped[B]" # noqa
index d29909c3c99265c8c6d4bd11207546bfa558c358..cbdbf009a0ed03507c3e927419af4af6d0ca07f1 100644 (file)
@@ -22,7 +22,6 @@ class User(Base):
 
     id = Column(Integer, primary_key=True)
 
-    # EXPECTED_MYPY: Unexpected keyword argument "wrong_arg" for "RelationshipProperty" # noqa
     addresses: Mapped[List["Address"]] = relationship(
         "Address", wrong_arg="imwrong"
     )
index 37f99502dbabe9e0c594bf0124164da87bdff5da..9b2853970139e006bd3e2bfda12c96ba599bf4a9 100644 (file)
@@ -8,7 +8,6 @@ from typing import cast
 from typing import List
 from typing import Tuple
 
-import sqlalchemy
 from sqlalchemy import testing
 from sqlalchemy.testing import config
 from sqlalchemy.testing import eq_
@@ -63,20 +62,8 @@ class MypyPluginTest(fixtures.TestBase):
             yield item
 
     def _cachedir(self):
-        sqlalchemy_path = os.path.dirname(os.path.dirname(sqlalchemy.__file__))
-
-        # for a pytest from my local ./lib/ , i need mypy_path.
-        # for a tox run where sqlalchemy is in site_packages, mypy complains
-        # "../python3.10/site-packages is in the MYPYPATH. Please remove it."
-        # previously when we used sqlalchemy2-stubs, it would just be
-        # installed as a dependency, which is why mypy_path wasn't needed
-        # then, but I like to be able to run the test suite from the local
-        # ./lib/ as well.
-
-        if "site-packages" not in sqlalchemy_path:
-            mypy_path = f"mypy_path={sqlalchemy_path}"
-        else:
-            mypy_path = ""
+        # as of mypy 0.971 i think we need to keep mypy_path empty
+        mypy_path = ""
 
         with tempfile.TemporaryDirectory() as cachedir:
             with open(
@@ -132,7 +119,8 @@ class MypyPluginTest(fixtures.TestBase):
 
             args.append(path)
 
-            return api.run(args)
+            result = api.run(args)
+            return result
 
         return run
 
@@ -286,6 +274,8 @@ class MypyPluginTest(fixtures.TestBase):
 
         result = mypy_runner(path, use_plugin=use_plugin)
 
+        not_located = []
+
         if expected_messages:
             eq_(result[2], 1, msg=result)
 
@@ -326,9 +316,15 @@ class MypyPluginTest(fixtures.TestBase):
                     ):
                         break
                 else:
+                    not_located.append(msg)
                     continue
                 del output[idx]
 
+            if not_located:
+                print(f"Couldn't locate expected messages: {not_located}")
+                print("\n".join(msg for _, msg in output))
+                assert False, "expected messages not found, see stdout"
+
             if output:
                 print(f"{len(output)} messages from mypy were not consumed:")
                 print("\n".join(msg for _, msg in output))