[Sqlalchemy-tickets] Issue #4221: non-mapped declared_attr warning gets in the way; is of questiona
Brought to you by:
zzzeek
From: Michael B. <iss...@bi...> - 2018-03-21 13:50:47
|
New issue 4221: non-mapped declared_attr warning gets in the way; is of questionable value https://bitbucket.org/zzzeek/sqlalchemy/issues/4221/non-mapped-declared_attr-warning-gets-in Michael Bayer: at http://docs.sqlalchemy.org/en/latest/orm/extensions/declarative/mixins.html#combining-table-mapper-arguments-from-multiple-mixins we document invoking `__table_args__` from a mixin. if `@declared_attr` is used we get a warning: ``` #!python from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.declarative import declared_attr Base = declarative_base() class Mixin(object): a = Column(Integer) @declared_attr def __table_args__(cls): return (UniqueConstraint("a"), ) class Baz(Base, Mixin): __tablename__ = 'baz' id = Column(Integer, primary_key=True) d = Column(Integer) @declared_attr def __table_args__(cls): ret = list(Mixin.__table_args__) ret.append(UniqueConstraint("d")) return tuple(ret) ``` SAWarning: Unmanaged access of declarative attribute __table_args__ from non-mapped class Mixin the thing we're guarding against here is the case in https://bitbucket.org/zzzeek/sqlalchemy/issues/3149/mixin_column-to-provide-more-context-for, which is already prevented here. not clear what additional case we are guarding against here however we could also limit the warning only for names that aren't `__table_args__`, `__mapper_args__`, etc. |