You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
New mypy update producing errors from "typical" sqlalchemy usage #2971
I'm not sure exactly what the cause of this is yet (still investigating), but I updated mypy and typed-ast today to the new versions and had a large number of errors start showing up. Here's an example of a really straightforward usage of SQLAlchemy (almost straight out of the ORM tutorial) that's now producing mypy errors:
from sqlalchemy import Column, String
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class User(Base):
__tablename__ = 'users'
name = Column(String)
def __init__(self, name: str) -> None:
self.name = name
The error is:
error: Incompatible types in assignment (expression has type "Column", variable has type "str")
I don't know much about sqlalchemy myself, but two places to look: (a) the stubs in typeshed for sqlalchemy were improved; (b) it looks like Column should be a descriptor (i.e. have at least a __get__ method) but maybe that's not in the stubs? The descriptor's return type would indicate the field type in the instance.
Thanks for such a quick response. It definitely seems to be related to the updated stubs, just removing the sqlalchemy stubs entirely gets rid of all the new errors.
I'm not familiar enough with how stubs work to know what might be the best approach for fixing this though. Do you think they should just be removed from typeshed in their current state, if they produce errors for normal sqlalchemy usage? Should I open an issue in the typeshed repo instead?
I don't think they should be removed (they are clearly useful for some people) but they should be fixed. Starting with an issue on typeshed sounds right -- call out the authors of the current stubs explicitly there.
Activity
gvanrossum commentedon Mar 6, 2017
I don't know much about sqlalchemy myself, but two places to look: (a) the stubs in typeshed for sqlalchemy were improved; (b) it looks like Column should be a descriptor (i.e. have at least a
__get__method) but maybe that's not in the stubs? The descriptor's return type would indicate the field type in the instance.Deimos commentedon Mar 7, 2017
Thanks for such a quick response. It definitely seems to be related to the updated stubs, just removing the sqlalchemy stubs entirely gets rid of all the new errors.
I'm not familiar enough with how stubs work to know what might be the best approach for fixing this though. Do you think they should just be removed from typeshed in their current state, if they produce errors for normal sqlalchemy usage? Should I open an issue in the typeshed repo instead?
gvanrossum commentedon Mar 7, 2017
I don't think they should be removed (they are clearly useful for some people) but they should be fixed. Starting with an issue on typeshed sounds right -- call out the authors of the current stubs explicitly there.
Deimos commentedon Mar 7, 2017
Sounds good, thanks. I'll close this one and open a new issue over there.