New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mypy 0.930: declarative_base() raises AssertionError #7496
Comments
yes it looks like mypy 9.3.0 just came out 3 hours ago and we are hitting it also. |
Mike Bayer has proposed a fix for this issue in the main branch: use fully qualified, locatable names for all use of api.named_type() https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3425 |
Mike Bayer has proposed a fix for this issue in the rel_1_4 branch: use fully qualified, locatable names for all use of api.named_type() https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3426 |
Fixed mypy regression where the release of mypy 0.930 added additional internal checks to the format of "named types", requiring that they be fully qualified and locatable. This broke the mypy plugin for SQLAlchemy, raising an assertion error, as there was use of symbols such as ``__builtins__`` and other un-locatable or unqualified names that previously had not raised any assertions. Fixes: #7496 Change-Id: I037680606a1d51158ef6503508ec76c5d5adc946 (cherry picked from commit aded8b1)
Note that the change is not backwards compatible, so you cannot use the plugin from 1.4.29 with mypy .910 |
@vfazio do you have a source for that? if it just "breaks" in .910 we may have just done the change incorrectly. if OTOH mypy has published that the calling API of api.named_type() is now backwards incompatible from .910 to .930 such that you can't write a single call to it which works in both versions, that seems like it should be noted on their side somewhere and would be a little bit surprising. |
Sure, I can demonstrate:
I haven't gotten much further in debugging |
Yeah I've no doubt you're getting a traceback like that. What we need is mypy devs to tell us how to use this method correctly. it shouldn't work by accident in one version one way, then another version in another way. getting mypy devs to clarify here is what we need. |
Apparently thats even with a hack i had in. I had changed the obj = ctx.api.named_type(names.NAMED_TYPE_BUILTINS_OBJECT) references to obj = ctx.api.object_type() to get those to shut up in .910 because of the change from python/mypy#6617 says "no guarantees about backwards compatibility" |
I apologize for the regression caused by the change of related APIs. |
OK is the API of this method now stable or do we have to fix it again? |
The current SemanticAnalyzer.named_type API works the same as TypeChecker.named_type. We would refactor the internal implementation of lookup functions in the future, but i think it wouldn't cause a regression change. |
Describe the bug
Running
mypy
version0.930
on a python file withbase = declarative_base()
causes an internal error with mypy using thesqlalchemy.ext.mypy.plugin
plugin.To Reproduce
Error
Versions
Additional context
No response
The text was updated successfully, but these errors were encountered: