From: Federico Caselli Date: Mon, 24 Feb 2025 19:46:09 +0000 (+0100) Subject: Remove declarative_mixin X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c3a8e7e6605475ddf5401af30ca81820d944a2ba;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Remove declarative_mixin Removed the ``declarative_mixin`` decorator since it was used only by the now removed mypy plugin. Fixes: #12346 Change-Id: I6709c7b33bf99ef94c3dc074a25386e8c13c9131 --- diff --git a/doc/build/changelog/unreleased_21/12346.rst b/doc/build/changelog/unreleased_21/12346.rst new file mode 100644 index 0000000000..9ed088596a --- /dev/null +++ b/doc/build/changelog/unreleased_21/12346.rst @@ -0,0 +1,6 @@ +.. change:: + :tags: typing, orm + :tickets: 12346 + + Deprecated the ``declarative_mixin`` decorator since it was used only + by the now removed mypy plugin. diff --git a/doc/build/orm/declarative_mixins.rst b/doc/build/orm/declarative_mixins.rst index 1c6179809a..8087276d91 100644 --- a/doc/build/orm/declarative_mixins.rst +++ b/doc/build/orm/declarative_mixins.rst @@ -724,7 +724,7 @@ define on the class itself. The here to create user-defined collation routines that pull from multiple collections:: - from sqlalchemy.orm import declarative_mixin, declared_attr + from sqlalchemy.orm import declared_attr class MySQLSettings: diff --git a/doc/build/orm/mapping_api.rst b/doc/build/orm/mapping_api.rst index 399111d605..f453429759 100644 --- a/doc/build/orm/mapping_api.rst +++ b/doc/build/orm/mapping_api.rst @@ -13,8 +13,6 @@ Class Mapping API .. autofunction:: declarative_base -.. autofunction:: declarative_mixin - .. autofunction:: as_declarative .. autofunction:: mapped_column diff --git a/lib/sqlalchemy/orm/decl_api.py b/lib/sqlalchemy/orm/decl_api.py index 97da200ef3..0fadd0f7fe 100644 --- a/lib/sqlalchemy/orm/decl_api.py +++ b/lib/sqlalchemy/orm/decl_api.py @@ -476,6 +476,11 @@ class _stateful_declared_attr(declared_attr[_T]): return declared_attr(fn, **self.kw) +@util.deprecated( + "2.1", + "The declarative_mixin decorator was used only by the now removed " + "mypy plugin so it has no longer any use and can be safely removed.", +) def declarative_mixin(cls: Type[_T]) -> Type[_T]: """Mark a class as providing the feature of "declarative mixin". diff --git a/test/orm/declarative/test_mixin.py b/test/orm/declarative/test_mixin.py index d670e96dcb..42745e4669 100644 --- a/test/orm/declarative/test_mixin.py +++ b/test/orm/declarative/test_mixin.py @@ -37,6 +37,7 @@ from sqlalchemy.testing import fixtures from sqlalchemy.testing import is_ from sqlalchemy.testing import is_true from sqlalchemy.testing import mock +from sqlalchemy.testing import uses_deprecated from sqlalchemy.testing.fixtures import fixture_session from sqlalchemy.testing.schema import Column from sqlalchemy.testing.schema import mapped_column @@ -299,6 +300,10 @@ class DeclarativeMixinTest(DeclarativeTestBase): eq_(obj.name, "testing") eq_(obj.foo(), "bar1") + @uses_deprecated( + "The declarative_mixin decorator was used only by the now removed " + "mypy plugin so it has no longer any use and can be safely removed." + ) def test_declarative_mixin_decorator(self): @declarative_mixin class MyMixin: