Skip to content

Hints do not work with imported Base #246

@Phinnik

Description

@Phinnik

There are no hints in PyCharm for models, which inherit declarative base from another module.
Here is example:

# base.py
import re

from sqlalchemy import Column, Integer, DateTime
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.sql import func
from sqlalchemy.ext.declarative import declarative_base


class Base:
    @declared_attr
    def __tablename__(cls):
        return cls.__name__.lower()

    id = Column(Integer, primary_key=True, index=True)
    created_at = Column(DateTime(timezone=True), nullable=False, server_default=func.now())


Base = declarative_base(cls=Base)
# models.py
from base import Base
from sqlalchemy import Integer, String, Column


class SomeModel(Base):
    id = Column(Integer, primary_key=True)
    name = Column(String)
    description = Column(String)

изображение

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions