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
Implement plugins to detect declarative bases #6
Comments
A potential problem here is how to store the fact that given |
Any news on this ? Currently declarative_base() seems to be inferred as Any. |
This doesn't seem to be fixed by #49 from typing import Any
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
reveal_type(Base) # revealed type is Any
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
name = Column(String)
class Address(Base):
__tablename__ = 'addresses'
id = Column(Integer, primary_key=True)
name = Column(String)
def f() -> Address:
user = User(name="xx")
return user # mypy should log an error here but doesn't |
It is. This is what I see
You need to enable the plugin in mypy config. Next time please make at least minimal effort before complaining. |
Ah sorry, I thought it would be enabled by installing sqlalchemy-stubs. My
bad.
I'm not complaining. I think you guys are doing great work, and i'm very
grateful :) !
I just report bugs or issues when i think there are ones. I always do my
best to reproduce a problem on a minimal case before reporting. Plugins are
not smth that is well documented, so it's sometimes hard to understand for
an outsider.
Thanks for the answer anyway !
Le 17 janv. 2019 4:21 PM, "Ivan Levkivskyi" <notifications@github.com> a
écrit :
… It is. This is what I see
main:8: error: Revealed type is 'def () -> main.Base'
main:25: error: Incompatible return value type (got "User", expected "Address")
You need to enable the plugin in mypy config. Next time please make at
least minimal effort before complaining.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#6 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ANBd8MmXHh_W6FapNL1Ohr6R89S6jixAks5vEJTpgaJpZM4WN-5s>
.
|
I wonder if the installation instructions in https://github.com/dropbox/sqlalchemy-stubs/blob/master/README.md are up-to-date with respect to the plugin? |
@mehdigmira OK, I am sorry for being harsh, it's great that we found understanding. @JukkaL Yes, I will update this before making the release. |
Fixes dropbox#23 Helps with dropbox#5 Fixes dropbox#6 Helps with dropbox#8 I would propose to merge this soon, and then iterate on discovered issues. This branch is very old, it is time to move on with some minimal version.
We currently can only detect declarative bases defined using
@as_declarative
, a plugin for detectingdeclarative_base()
depends on python/mypy#5508The text was updated successfully, but these errors were encountered: