--- /dev/null
+.. change::
+ :tags: bug, orm, mypy
+ :tickets: 7368
+
+ Fixed issue where the ``__class_getitem__()`` method of the generated declarative base class by
+ :func:`_orm.as_declarative` lead to inaccessible class attributes such as ``__table__``.
+ Pull request courtesy Kai Mueller.
if mapper:
class_dict["__mapper_cls__"] = mapper
if hasattr(cls, "__class_getitem__"):
- class_dict["__class_getitem__"] = cls.__class_getitem__
+ class_dict["__class_getitem__"] = lambda cls, _: cls
return metaclass(name, bases, class_dict)
@as_declarative()
class Base(CommonBase[T]):
- pass
+ foo = 1
class Tab(Base["Tab"]):
+ __tablename__ = "foo"
a = Column(Integer, primary_key=True)
+
+ assert Tab.foo == 1
+ assert Tab.__table__ is not None
+ assert Tab.boring() == Tab