-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Code wich uses DeclarativeMeta crashes mypy #9102
Comments
Hi, Thanks for reporting. Moving to sqlalchemy repo since the mypy plugin is in sqlalchemy |
if you are only using the dev version of mypy, mypy just made a change here at python/mypy#6617 (comment) which may or may not be related. would need to know what versions of mypy reproduce the issue. |
Thanks for the quick answer :) This bug happens on the latest release of mypy as well. We noticed it on the release version(0.991) |
oh ok, so not a regression, just a new issue beginning to use mypy. Can I perhaps talk you into upgrading to SQLAlchemy 2.0 first before starting efforts with mypy? The approach to typing has changed dramatically and you will get vastly better (and much better supported by me) results in SQLAlchemy 2.0. First release is before the end of the month. |
I agree that this is the best way forward. The project this code is taken from is already fully compliant with 2.0. The code runs just fine, but the type hints are a mess. SQL Alchemy causes ~100 errors across our codebase. These are the remaining errors on our way to 100% mypy compliancy. The matter is not particularly urgent, but our attempts up until today have been futile. |
oh, forget it, typing in 1.4 was a hack to get something out the door. 2.0 is where I changed the foundational assumptions of everything and introduced an all-new declarative system to get typing to work. You'd have to use 2.0 patterns in your ORM models to get full typing support, though. overall if things aren't "urgent", let 2.0 come out and then see if you can get onto that release in the next few months, then do the typing. |
Mike Bayer has proposed a fix for this issue in the rel_1_4 branch: mypy plugin fixes https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/4365 |
Mike Bayer has proposed a fix for this issue in the main branch: mypy plugin fixes https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/4366 |
Adjustments made to the mypy plugin to accommodate for some potential changes being made for issue #236 sqlalchemy2-stubs when using SQLAlchemy 1.4. These changes are being kept in sync within SQLAlchemy 2.0. The changes are also backwards compatible with older versions of sqlalchemy2-stubs. Fixed crash in mypy plugin which could occur on both 1.4 and 2.0 versions if a decorator for the :func:`_orm.registry.mapped` decorator were used that was referenced in an expression with more than two components (e.g. ``@Backend.mapper_registry.mapped``). This scenario is now ignored; when using the plugin, the decorator expression needs to be two components (i.e. ``@reg.mapped``). References: sqlalchemy/sqlalchemy2-stubs#236 Fixes: #9102 Change-Id: Ieb1bf7bf8184645bcd43253e57f1c267b2640537 (cherry picked from commit cf64582f61b15716228302f669322d7efa1003c1) (cherry picked from commit 36285760238314f70eed4532ca2c2c0c2d684609)
Describe the bug
The provided code snippet crashes mypy.
Expected behavior
The code snippet should be parsed without a crash.
To Reproduce
Install the provided versions of sql alchemy, this plugin, and mypy.
Create a file test.py with the following content:
Error without traceback
Error with traceback
Versions.
Additional context
This code snippet has been obtained by striping away most of the details from code that has been running fine for years.
We are trying to setup mypy and ran into trouble during that.
Have a nice day!
The text was updated successfully, but these errors were encountered: