Skip to content

Commit 31557eb

Browse files
authored
feat!: remove deprecated packages removed in v1.0.0 (#419)
Removes all code that was deprecated and marked for removal in version 1.0.0
1 parent a432330 commit 31557eb

6 files changed

Lines changed: 29 additions & 166 deletions

File tree

advanced_alchemy/base.py

Lines changed: 16 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -23,74 +23,45 @@
2323
from typing_extensions import Self, TypeVar
2424

2525
from advanced_alchemy.mixins import (
26-
AuditColumns as _AuditColumns,
27-
)
28-
from advanced_alchemy.mixins import (
29-
BigIntPrimaryKey as _BigIntPrimaryKey,
30-
)
31-
from advanced_alchemy.mixins import (
32-
NanoIDPrimaryKey as _NanoIDPrimaryKey,
33-
)
34-
from advanced_alchemy.mixins import (
35-
UUIDPrimaryKey as _UUIDPrimaryKey,
36-
)
37-
from advanced_alchemy.mixins import (
38-
UUIDv6PrimaryKey as _UUIDv6PrimaryKey,
39-
)
40-
from advanced_alchemy.mixins import (
41-
UUIDv7PrimaryKey as _UUIDv7PrimaryKey,
26+
AuditColumns,
27+
BigIntPrimaryKey,
28+
NanoIDPrimaryKey,
29+
UUIDPrimaryKey,
30+
UUIDv6PrimaryKey,
31+
UUIDv7PrimaryKey,
4232
)
4333
from advanced_alchemy.types import GUID, DateTimeUTC, JsonB
4434
from advanced_alchemy.utils.dataclass import DataclassProtocol
45-
from advanced_alchemy.utils.deprecation import warn_deprecation
4635

4736
if TYPE_CHECKING:
48-
# these should stay here since they are deprecated. They are imported in the __getattr__ function
4937
from sqlalchemy.sql import FromClause
5038
from sqlalchemy.sql.schema import (
5139
_NamingSchemaParameter as NamingSchemaParameter, # pyright: ignore[reportPrivateUsage]
5240
)
5341

54-
from advanced_alchemy.mixins import (
55-
AuditColumns,
56-
BigIntPrimaryKey,
57-
NanoIDPrimaryKey,
58-
SlugKey,
59-
UUIDPrimaryKey,
60-
UUIDv6PrimaryKey,
61-
UUIDv7PrimaryKey,
62-
)
63-
6442

6543
__all__ = (
6644
"AdvancedDeclarativeBase",
67-
"AuditColumns",
6845
"BasicAttributes",
6946
"BigIntAuditBase",
7047
"BigIntBase",
7148
"BigIntBaseT",
72-
"BigIntPrimaryKey",
7349
"CommonTableAttributes",
7450
"ModelProtocol",
7551
"NanoIDAuditBase",
7652
"NanoIDBase",
7753
"NanoIDBaseT",
78-
"NanoIDPrimaryKey",
7954
"SQLQuery",
80-
"SlugKey",
8155
"TableArgsType",
8256
"UUIDAuditBase",
8357
"UUIDBase",
8458
"UUIDBaseT",
85-
"UUIDPrimaryKey",
8659
"UUIDv6AuditBase",
8760
"UUIDv6Base",
8861
"UUIDv6BaseT",
89-
"UUIDv6PrimaryKey",
9062
"UUIDv7AuditBase",
9163
"UUIDv7Base",
9264
"UUIDv7BaseT",
93-
"UUIDv7PrimaryKey",
9465
"convention",
9566
"create_registry",
9667
"merge_table_arguments",
@@ -100,42 +71,6 @@
10071
)
10172

10273

103-
def __getattr__(attr_name: str) -> object:
104-
if attr_name == "__path__":
105-
return __file__
106-
107-
_deprecated_attrs = {
108-
"SlugKey",
109-
"AuditColumns",
110-
"NanoIDPrimaryKey",
111-
"BigIntPrimaryKey",
112-
"UUIDPrimaryKey",
113-
"UUIDv6PrimaryKey",
114-
"UUIDv7PrimaryKey",
115-
}
116-
if attr_name in _deprecated_attrs:
117-
from advanced_alchemy import mixins
118-
119-
module = "advanced_alchemy.mixins"
120-
value = globals()[attr_name] = getattr(mixins, attr_name)
121-
122-
warn_deprecation(
123-
deprecated_name=f"advanced_alchemy.base.{attr_name}",
124-
version="0.26.0",
125-
kind="import",
126-
removal_in="1.0.0",
127-
info=f"importing {attr_name} from 'advanced_alchemy.base' is deprecated, please import it from '{module}' instead",
128-
)
129-
130-
return value
131-
if attr_name in set(__all__).difference(_deprecated_attrs):
132-
value = globals()[attr_name] = locals()[attr_name]
133-
return value
134-
135-
msg = f"module {__name__!r} has no attribute {attr_name!r}"
136-
raise AttributeError(msg)
137-
138-
13974
UUIDBaseT = TypeVar("UUIDBaseT", bound="UUIDBase")
14075
"""Type variable for :class:`UUIDBase`."""
14176
BigIntBaseT = TypeVar("BigIntBaseT", bound="BigIntBase")
@@ -385,7 +320,7 @@ def __init_subclass__(cls, **kwargs: Any) -> None:
385320
super().__init_subclass__(**kwargs)
386321

387322

388-
class UUIDBase(_UUIDPrimaryKey, CommonTableAttributes, AdvancedDeclarativeBase, AsyncAttrs):
323+
class UUIDBase(UUIDPrimaryKey, CommonTableAttributes, AdvancedDeclarativeBase, AsyncAttrs):
389324
"""Base for all SQLAlchemy declarative models with UUID v4 primary keys.
390325
391326
.. seealso::
@@ -398,7 +333,7 @@ class UUIDBase(_UUIDPrimaryKey, CommonTableAttributes, AdvancedDeclarativeBase,
398333
__abstract__ = True
399334

400335

401-
class UUIDAuditBase(CommonTableAttributes, _UUIDPrimaryKey, _AuditColumns, AdvancedDeclarativeBase, AsyncAttrs):
336+
class UUIDAuditBase(CommonTableAttributes, UUIDPrimaryKey, AuditColumns, AdvancedDeclarativeBase, AsyncAttrs):
402337
"""Base for declarative models with UUID v4 primary keys and audit columns.
403338
404339
.. seealso::
@@ -412,7 +347,7 @@ class UUIDAuditBase(CommonTableAttributes, _UUIDPrimaryKey, _AuditColumns, Advan
412347
__abstract__ = True
413348

414349

415-
class UUIDv6Base(_UUIDv6PrimaryKey, CommonTableAttributes, AdvancedDeclarativeBase, AsyncAttrs):
350+
class UUIDv6Base(UUIDv6PrimaryKey, CommonTableAttributes, AdvancedDeclarativeBase, AsyncAttrs):
416351
"""Base for all SQLAlchemy declarative models with UUID v6 primary keys.
417352
418353
.. seealso::
@@ -425,7 +360,7 @@ class UUIDv6Base(_UUIDv6PrimaryKey, CommonTableAttributes, AdvancedDeclarativeBa
425360
__abstract__ = True
426361

427362

428-
class UUIDv6AuditBase(CommonTableAttributes, _UUIDv6PrimaryKey, _AuditColumns, AdvancedDeclarativeBase, AsyncAttrs):
363+
class UUIDv6AuditBase(CommonTableAttributes, UUIDv6PrimaryKey, AuditColumns, AdvancedDeclarativeBase, AsyncAttrs):
429364
"""Base for declarative models with UUID v6 primary keys and audit columns.
430365
431366
.. seealso::
@@ -439,7 +374,7 @@ class UUIDv6AuditBase(CommonTableAttributes, _UUIDv6PrimaryKey, _AuditColumns, A
439374
__abstract__ = True
440375

441376

442-
class UUIDv7Base(_UUIDv7PrimaryKey, CommonTableAttributes, AdvancedDeclarativeBase, AsyncAttrs):
377+
class UUIDv7Base(UUIDv7PrimaryKey, CommonTableAttributes, AdvancedDeclarativeBase, AsyncAttrs):
443378
"""Base for all SQLAlchemy declarative models with UUID v7 primary keys.
444379
445380
.. seealso::
@@ -452,7 +387,7 @@ class UUIDv7Base(_UUIDv7PrimaryKey, CommonTableAttributes, AdvancedDeclarativeBa
452387
__abstract__ = True
453388

454389

455-
class UUIDv7AuditBase(CommonTableAttributes, _UUIDv7PrimaryKey, _AuditColumns, AdvancedDeclarativeBase, AsyncAttrs):
390+
class UUIDv7AuditBase(CommonTableAttributes, UUIDv7PrimaryKey, AuditColumns, AdvancedDeclarativeBase, AsyncAttrs):
456391
"""Base for declarative models with UUID v7 primary keys and audit columns.
457392
458393
.. seealso::
@@ -466,7 +401,7 @@ class UUIDv7AuditBase(CommonTableAttributes, _UUIDv7PrimaryKey, _AuditColumns, A
466401
__abstract__ = True
467402

468403

469-
class NanoIDBase(_NanoIDPrimaryKey, CommonTableAttributes, AdvancedDeclarativeBase, AsyncAttrs):
404+
class NanoIDBase(NanoIDPrimaryKey, CommonTableAttributes, AdvancedDeclarativeBase, AsyncAttrs):
470405
"""Base for all SQLAlchemy declarative models with Nano ID primary keys.
471406
472407
.. seealso::
@@ -479,7 +414,7 @@ class NanoIDBase(_NanoIDPrimaryKey, CommonTableAttributes, AdvancedDeclarativeBa
479414
__abstract__ = True
480415

481416

482-
class NanoIDAuditBase(CommonTableAttributes, _NanoIDPrimaryKey, _AuditColumns, AdvancedDeclarativeBase, AsyncAttrs):
417+
class NanoIDAuditBase(CommonTableAttributes, NanoIDPrimaryKey, AuditColumns, AdvancedDeclarativeBase, AsyncAttrs):
483418
"""Base for declarative models with Nano ID primary keys and audit columns.
484419
485420
.. seealso::
@@ -493,7 +428,7 @@ class NanoIDAuditBase(CommonTableAttributes, _NanoIDPrimaryKey, _AuditColumns, A
493428
__abstract__ = True
494429

495430

496-
class BigIntBase(_BigIntPrimaryKey, CommonTableAttributes, AdvancedDeclarativeBase, AsyncAttrs):
431+
class BigIntBase(BigIntPrimaryKey, CommonTableAttributes, AdvancedDeclarativeBase, AsyncAttrs):
497432
"""Base for all SQLAlchemy declarative models with BigInt primary keys.
498433
499434
.. seealso::
@@ -506,7 +441,7 @@ class BigIntBase(_BigIntPrimaryKey, CommonTableAttributes, AdvancedDeclarativeBa
506441
__abstract__ = True
507442

508443

509-
class BigIntAuditBase(CommonTableAttributes, _BigIntPrimaryKey, _AuditColumns, AdvancedDeclarativeBase, AsyncAttrs):
444+
class BigIntAuditBase(CommonTableAttributes, BigIntPrimaryKey, AuditColumns, AdvancedDeclarativeBase, AsyncAttrs):
510445
"""Base for declarative models with BigInt primary keys and audit columns.
511446
512447
.. seealso::

advanced_alchemy/exceptions.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@
77
from sqlalchemy.exc import InvalidRequestError as SQLAlchemyInvalidRequestError
88
from sqlalchemy.exc import MultipleResultsFound, SQLAlchemyError, StatementError
99

10-
from advanced_alchemy.utils.deprecation import deprecated
11-
1210
__all__ = (
1311
"AdvancedAlchemyError",
14-
"ConflictError",
1512
"DuplicateKeyError",
1613
"ErrorMessages",
1714
"ForeignKeyError",
@@ -173,28 +170,6 @@ class RepositoryError(AdvancedAlchemyError):
173170
"""
174171

175172

176-
class ConflictError(RepositoryError):
177-
"""Data integrity error.
178-
179-
Args:
180-
*args: Variable length argument list passed to parent class.
181-
detail: Detailed error message.
182-
183-
Note:
184-
This class is deprecated in favor of :class:`advanced_alchemy.exceptions.IntegrityError`.
185-
"""
186-
187-
@deprecated(
188-
version="0.7.1",
189-
alternative="advanced_alchemy.exceptions.IntegrityError",
190-
kind="method",
191-
removal_in="1.0.0",
192-
info="`ConflictError` has been renamed to `IntegrityError`",
193-
)
194-
def __init__(self, *args: Any, detail: str = "") -> None:
195-
super().__init__(*args, detail=detail)
196-
197-
198173
class IntegrityError(RepositoryError):
199174
"""Data integrity error.
200175

advanced_alchemy/utils/deprecation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def deprecated(
7878
"""Create a decorator wrapping a function, method or property with a warning call about a (pending) deprecation.
7979
8080
Args:
81-
version: Litestar version where the deprecation will occur
82-
removal_in: Litestar version where the deprecated function will be removed
81+
version: Advanced Alchemy version where the deprecation will occur
82+
removal_in: Advanced Alchemy version where the deprecated function will be removed
8383
alternative: Name of a function that should be used instead
8484
info: Additional information
8585
pending: Use :class:`warnings.PendingDeprecationWarning` instead of :class:`warnings.DeprecationWarning`

tests/unit/test_base.py

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,11 @@
44

55
import warnings
66

7-
import pytest
8-
97
from tests.helpers import purge_module
108

119

12-
def test_deprecated_uuid_primary_keys() -> None:
13-
"""Test that using UUIDv7PrimaryKey from base raises a deprecation warning."""
14-
purge_module(["advanced_alchemy.base"], __file__)
15-
with pytest.warns(DeprecationWarning, match="please import it from 'advanced_alchemy.mixins' instead"):
16-
from advanced_alchemy.base import UUIDv7PrimaryKey
17-
18-
with pytest.warns(DeprecationWarning, match="please import it from 'advanced_alchemy.mixins' instead"):
19-
from advanced_alchemy.base import UUIDv6PrimaryKey
20-
21-
with pytest.warns(DeprecationWarning, match="please import it from 'advanced_alchemy.mixins' instead"):
22-
from advanced_alchemy.base import UUIDPrimaryKey
23-
24-
25-
def test_deprecated_slug_mixin() -> None:
26-
"""Test that using SlugMixin from base raises a deprecation warning."""
27-
purge_module(["advanced_alchemy.base", "advanced_alchemy.mixins.slug", "advanced_alchemy.mixins"], __file__)
28-
with pytest.warns(DeprecationWarning, match="please import it from 'advanced_alchemy.mixins' instead"):
29-
from advanced_alchemy.base import SlugKey
30-
31-
32-
def test_deprecated_bigint_primary_key() -> None:
33-
"""Test that using BigIntPrimaryKey from base raises a deprecation warning."""
34-
purge_module(["advanced_alchemy.base", "advanced_alchemy.mixins.bigint", "advanced_alchemy.mixins"], __file__)
35-
with pytest.warns(DeprecationWarning, match="please import it from 'advanced_alchemy.mixins' instead"):
36-
from advanced_alchemy.base import BigIntPrimaryKey
37-
38-
39-
def test_deprecated_nanoid_primary_key() -> None:
40-
"""Test that using NanoIDPrimaryKey from base raises a deprecation warning."""
41-
purge_module(["advanced_alchemy.base", "advanced_alchemy.mixins.nanoid", "advanced_alchemy.mixins"], __file__)
42-
with pytest.warns(DeprecationWarning, match="please import it from 'advanced_alchemy.mixins' instead"):
43-
from advanced_alchemy.base import NanoIDPrimaryKey
44-
45-
46-
def test_deprecated_audit_columns() -> None:
47-
"""Test that using AuditColumns from base raises a deprecation warning."""
48-
purge_module(["advanced_alchemy.base", "advanced_alchemy.mixins.audit", "advanced_alchemy.mixins"], __file__)
49-
with pytest.warns(DeprecationWarning, match="please import it from 'advanced_alchemy.mixins' instead"):
50-
from advanced_alchemy.base import AuditColumns
51-
52-
5310
def test_deprecated_classes_functionality() -> None:
54-
"""Test that deprecated classes maintain functionality while warning."""
11+
"""Test that mixins classes maintain have base functionality."""
5512
purge_module(["advanced_alchemy.base", "advanced_alchemy.mixins"], __file__)
5613

5714
warnings.filterwarnings("ignore", category=DeprecationWarning)
@@ -60,7 +17,13 @@ def test_deprecated_classes_functionality() -> None:
6017
warnings.filterwarnings("ignore", category=sa_exc.SAWarning)
6118

6219
# Test instantiation and basic attributes
63-
from advanced_alchemy.base import AuditColumns, NanoIDPrimaryKey, UUIDPrimaryKey, UUIDv6PrimaryKey, UUIDv7PrimaryKey
20+
from advanced_alchemy.mixins import (
21+
AuditColumns,
22+
NanoIDPrimaryKey,
23+
UUIDPrimaryKey,
24+
UUIDv6PrimaryKey,
25+
UUIDv7PrimaryKey,
26+
)
6427

6528
uuidv7_pk = UUIDv7PrimaryKey()
6629
uuidv6_pk = UUIDv6PrimaryKey()

tests/unit/test_exceptions.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import contextlib
2-
31
import pytest
42
from sqlalchemy.exc import (
53
IntegrityError as SQLAlchemyIntegrityError,
@@ -24,14 +22,6 @@
2422
)
2523

2624

27-
async def test_repo_get_or_create_deprecation() -> None:
28-
with pytest.warns(DeprecationWarning):
29-
from advanced_alchemy.exceptions import ConflictError
30-
31-
with contextlib.suppress(Exception):
32-
raise ConflictError
33-
34-
3525
def test_wrap_sqlalchemy_exception_multiple_results_found() -> None:
3626
with pytest.raises(MultipleResultsFoundError), wrap_sqlalchemy_exception():
3727
raise MultipleResultsFound()

uv.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)