From: Mike Bayer Date: Sat, 23 Jul 2022 14:18:06 +0000 (-0400) Subject: remove mypy_path workaround and ensure messages received X-Git-Tag: rel_2_0_0b1~161 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4fe222d9412df30fc15ace3d7a7fd4365eb9e05a;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git remove mypy_path workaround and ensure messages received Fixes: #8281 Change-Id: Ice47880ba7924daff68aef6b1791f3c66849f550 --- diff --git a/test/ext/mypy/plugin_files/relationship_err1.py b/test/ext/mypy/plugin_files/relationship_err1.py index ba3783f05a..46e7067d34 100644 --- a/test/ext/mypy/plugin_files/relationship_err1.py +++ b/test/ext/mypy/plugin_files/relationship_err1.py @@ -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) diff --git a/test/ext/mypy/plugin_files/relationship_err3.py b/test/ext/mypy/plugin_files/relationship_err3.py index aa76ae1f0e..1c7cd9f303 100644 --- a/test/ext/mypy/plugin_files/relationship_err3.py +++ b/test/ext/mypy/plugin_files/relationship_err3.py @@ -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 diff --git a/test/ext/mypy/plugin_files/typing_err3.py b/test/ext/mypy/plugin_files/typing_err3.py index d29909c3c9..cbdbf009a0 100644 --- a/test/ext/mypy/plugin_files/typing_err3.py +++ b/test/ext/mypy/plugin_files/typing_err3.py @@ -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" ) diff --git a/test/ext/mypy/test_mypy_plugin_py3k.py b/test/ext/mypy/test_mypy_plugin_py3k.py index 37f99502db..9b28539701 100644 --- a/test/ext/mypy/test_mypy_plugin_py3k.py +++ b/test/ext/mypy/test_mypy_plugin_py3k.py @@ -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))