[Sqlalchemy-tickets] Issue #4364: Code completion in IDEs with Session objects doesn't work (zzzeek
Brought to you by:
zzzeek
From: Michael R. <iss...@bi...> - 2018-11-12 13:52:44
|
New issue 4364: Code completion in IDEs with Session objects doesn't work https://bitbucket.org/zzzeek/sqlalchemy/issues/4364/code-completion-in-ides-with-session Michael Rans: If I create a Session object, I do not get code completion for it in my IDE (PyCharm) even if I add a type hint. ``` #!python from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base, declared_attr from sqlalchemy.orm import sessionmaker from sqlalchemy.pool import NullPool class HDXBase(object): @declared_attr def __tablename__(cls): return '%ss' % cls.__name__.lower() engine = create_engine('sqlite:///test.db', poolclass=NullPool, echo=False) Session = sessionmaker(bind=engine) Base = declarative_base(cls=HDXBase) Base.metadata.create_all(engine) session = Session() ``` If after entering the above I type "session." in PyCharm, there are no options given from the Session class. ``` #!python def get_session(db_url): # type: (str) -> sqlalchemy.orm.session.Session engine = create_engine(db_url, poolclass=NullPool, echo=False) Session = sessionmaker(bind=engine) Base = declarative_base(cls=HDXBase) Base.metadata.create_all(engine) return Session() session = get_session('sqlite:///test.db') ``` If after entering the above I type "session." in PyCharm, there are no options given from the Session class. Also I notice an error "Cannot find reference 'orm' in '__init__.py'" |