-
-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: deprecate
litestar.contrib.sqlalchemy
(#3755)
* feat: deprecate `contrib.sqlalchemy` * feat: linting * feat: deprecate `contrib.sqlalchemy` * feat: linting * fix: correct variable reference * fix: corrected deprecated version * chore: linting * feat: fix changes caused by linting * fix: linting * chore: bump deps * fix: test case corrections * fix: revert lock file changes * feat: remove extra ignores * feat: adds additional coverage * feat: additional coverage * chore: ignore catchall coverage
- Loading branch information
Showing
40 changed files
with
1,286 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,3 +47,4 @@ __pypackages__/ | |
# test certificates | ||
certs/ | ||
pdm.toml | ||
.zed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# ruff: noqa: TCH004, F401 | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from litestar.utils import warn_deprecation | ||
|
||
__all__ = ( | ||
"SQLAlchemyAsyncRepository", | ||
"SQLAlchemySyncRepository", | ||
"ModelT", | ||
"wrap_sqlalchemy_exception", | ||
) | ||
|
||
|
||
def __getattr__(attr_name: str) -> object: | ||
if attr_name in __all__: | ||
if attr_name in ("SQLAlchemyAsyncRepository", "SQLAlchemySyncRepository", "ModelT"): | ||
module = "litestar.plugins.sqlalchemy.repository" | ||
from advanced_alchemy.extensions.litestar import ( | ||
repository, # type: ignore[import-not-found] # pyright: ignore[reportMissingImports] | ||
) | ||
|
||
value = globals()[attr_name] = getattr(repository, attr_name) | ||
elif attr_name == "wrap_sqlalchemy_exception": | ||
module = "litestar.plugins.sqlalchemy.exceptions" | ||
from advanced_alchemy.extensions.litestar import ( | ||
exceptions, # type: ignore[import-not-found] # pyright: ignore[reportMissingImports] | ||
) | ||
|
||
value = globals()[attr_name] = getattr(exceptions, attr_name) | ||
warn_deprecation( | ||
deprecated_name=f"litestar.contrib.sqlalchemy.{attr_name}", | ||
version="2.12", | ||
kind="import", | ||
removal_in="3.0", | ||
info=f"importing {attr_name} from 'litestar.contrib.sqlalchemy' is deprecated, please " | ||
f"import it from '{module}' instead", | ||
) | ||
|
||
return value | ||
|
||
raise AttributeError(f"module {__name__!r} has no attribute {attr_name!r}") # pragma: no cover | ||
|
||
|
||
if TYPE_CHECKING: | ||
from advanced_alchemy.exceptions import ( # type: ignore[import-not-found] # pyright: ignore[reportMissingImports] | ||
wrap_sqlalchemy_exception, | ||
) | ||
from advanced_alchemy.repository import ( # type: ignore[import-not-found] # pyright: ignore[reportMissingImports] | ||
ModelT, | ||
SQLAlchemyAsyncRepository, | ||
SQLAlchemySyncRepository, | ||
) |
Oops, something went wrong.