🐛 Move `__tablename__` default from `@declared_attr` to metaclass by estarfoo · Pull Request #1821 · fastapi/sqlmodel
The `SQLModel` base class declared `__tablename__` both as a `ClassVar` and as a `@declared_attr` method. Some type checkers (pyright) see the descriptor type from `@declared_attr`, so setting `__tablename__ = "my_table"` in a subclass is rejected as a type mismatch, even though it works at runtime. Replace the `@declared_attr` method with a default set in `SQLModelMetaclass.__new__` via `dict_used`, before class creation. Fixes fastapi#98. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>