-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Avoid deprecated sqlalchemy URL constructor.
- Loading branch information
Showing
7 changed files
with
22 additions
and
11 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
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 |
---|---|---|
@@ -1,10 +1,21 @@ | ||
import sqlalchemy.engine.url | ||
|
||
from pytest_mock_resources.compat.import_ import ImportAdaptor | ||
|
||
try: | ||
from sqlalchemy.ext import asyncio as asyncio # type: ignore | ||
from sqlalchemy.ext import asyncio # type: ignore | ||
except ImportError: | ||
asyncio = ImportAdaptor( # type: ignore | ||
asyncio = ImportAdaptor( | ||
"SQLAlchemy", | ||
"SQLAlchemy >= 1.4", | ||
fail_message="Cannot use sqlalchemy async features with SQLAlchemy < 1.4.\n", | ||
) | ||
|
||
URL = sqlalchemy.engine.url.URL | ||
try: | ||
# Attempt to use the newly recommended `URL.create` method when available | ||
URL = URL.create # type: ignore | ||
except AttributeError: | ||
# But if it's not available, the top-level contructor should still exist, | ||
# as this is the only available option in sqlalchemy<1.4 versions. | ||
pass |
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