Skip to content

Ignore classvar attributes defined in declarative classes #9833

Description

@CaselIT

Something that certainly should work, but does not, is to declare the type as a ClassVar[], since we scan these also in declarative:

class AlertItem2(Base):
    __tablename__ = "alert_items2"
    id = Column(BigInteger, primary_key=True, autoincrement=True)
    signature = Column(String)
    data_source_model_id = Column(Integer)

    _only_unique_unresolved_alerts: ClassVar[Any] = data_source_model_id == None

    __table_args__ = (
        Index(
            "_uq",
            signature,
            postgresql_where=_only_unique_unresolved_alerts,
            unique=True,
        ),
    )

we can add an issue for that use case and also augment the warning with this approach.

Originally posted by @zzzeek in #9826 (reply in thread)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ormorm - annotated declarativeissues with the new annotations-based declarative ORM approachuse casenot really a feature or a bug; can be support for new DB features or user use cases not anticipated

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions