-
Notifications
You must be signed in to change notification settings - Fork 41
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
Make Column and relationship inherit from Mapped #235
Comments
Thanks for reporting Sadly this will not be fixed in 1.4. In version 2 it will be fixed |
on second though, we can just lie to the type checker I guess, by making Column inherit Mapped only on the stubs. Do you have any reservation with that @zzzeek ? |
Yes that what I meant. Mapped is used for typing essentially, So it's a bit weird that the recommended way of typing columns is wrong from a typing point of view. |
I think this is a problem in mypy also, but was only hidden by an import issue (#237). |
I've dug into this a bit: Making Column inherit from Mapped causes some MRO problems, since Mapped and ColumnClause share some base classes. |
Is your feature request related to a problem? Please describe.
A typical typed SQLAlchemy model looks like this:
This works fine with mypy, but triggers the following error with Pylance/Pyright
Same for relationship
Describe the solution you'd like
Make Column and relationship inherit from Mapped
Additional context
I can make a PR if you're okay with this.
Have a nice day!
The text was updated successfully, but these errors were encountered: