Diagrams can't recognize Sqlalchemy model dependencies across modules?

I have a bunch of SQLAlchemy models spread across different modules in a package. When I open a model dependency diagram for the package, Pycharm correctly recognizes the relationships between models in the same file, but not ones in different files.

Is there some way I can nudge Pycharm into recognizing the relationships? Is this a bug? (Or perhaps I'm the bug - maybe there's a good reason to keep all models together...?)

Here's a simple example. As written, Pycharm correctly observes the link between Spam and Eggs. But if you move the Eggs class to another module, Pycharm fails to observe the link.

Example
from sqlalchemy import Column, Integer, ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, relationship

from sqlalchemy import create_engine

Base = declarative_base()

class Spam(Base):

    __tablename__ = "spams"

    id = Column(Integer, primary_key=True)

class Eggs(Base):

    __tablename__ = "eggs"


    id = Column(Integer, primary_key=True)
    spamid = Column(Integer, ForeignKey("spams.id"))

    spam = relationship("Spam")

if __name__ == '__main__':
    engine = create_engine("sqlite:///spam.db")
    Session = sessionmaker(engine)
    Base.metadata.create_all(engine)
    s = Session()
1
Hi Colin,

it looks like a bug there. Please, file an issue in our tracker – http://youtrack.jetbrains.com/issues/PY
0
Avatar
Permanently deleted user

Is there any update on this?
I'm experiencing the same problem with PyCharm Professional 2016.1.2.

0

请先登录再写评论。