Skip to content

Commit a749a60

Browse files
committed
🐛 fix(alembic): editable check in Python 3.9
1 parent be74781 commit a749a60

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

nonebot_plugin_orm/migrate.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,17 @@ def _init_version_locations(self) -> None:
258258
if plugin.metadata and (
259259
version_module := plugin.metadata.extra.get("orm_version_location")
260260
):
261-
version_location = files(version_module)
261+
if sys.version_info[:2] == (3, 9):
262+
# importlib_resources.files() return a opaque Traversable object
263+
# even if the anchor is a namespace package in Python 3.9
264+
version_location = Path(version_module.__path__[0])
265+
else:
266+
version_location = files(version_module)
262267
else:
263-
version_location = files(plugin.module) / "migrations"
268+
if sys.version_info[:2] == (3, 9):
269+
version_location = Path(plugin.module.__path__[0]) / "migrations"
270+
else:
271+
version_location = files(plugin.module) / "migrations"
264272

265273
temp_version_location = Path(
266274
*map(attrgetter("name"), reversed(list(get_parent_plugins(plugin)))),

0 commit comments

Comments
 (0)