Thanks to visit codestin.com
Credit goes to github.com

Skip to content

anyio used in aerich/utils.py but not defined in project dependencies #480

@seriaati

Description

@seriaati

As title says, aerich/utils.py uses anyio:

from anyio import from_thread

But in pyproject.toml, anyio is not in the dependencies:

aerich/pyproject.toml

Lines 12 to 16 in 1245ec4

dependencies = [
"tortoise-orm (>=0.21.0,<1.0.0)",
"dictdiffer (>=0.9.0,<1.0.0)",
"asyncclick (>=8.1.7,<9.0.0)",
]

This will cause Tortoise ORM init to fail if "aerich.models" is defined in the config:

5|embed-fixer  | Traceback (most recent call last):
5|embed-fixer  |   File "/root/repos/embed-fixer/.venv/lib/python3.12/site-packages/tortoise/__init__.py", line 292, in _discover_models
5|embed-fixer  |     module = importlib.import_module(models_path)
5|embed-fixer  |              ^^^^^^^^^^^^^^^^^^^^^^^
5|embed-fixer  | ^^^^^^^^^^^^^
5|embed-fixer  |   File "/root/.pyenv/versions/3.12.5/lib/python3.12/importlib/__init__.py", line 90, in import_module
5|embed-fixer  |     return _bootstrap._gcd_import(name[level:], package, level)
5|embed-fixer  |            ^
5|embed-fixer  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5|embed-fixer  |   File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
5|embed-fixer  |   File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
5|embed-fixer  |   File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
5|embed-fixer  |   File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
5|embed-fixer  |   File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
5|embed-fixer  |   File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
5|embed-fixer  |   File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
5|embed-fixer  |   File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
5|embed-fixer  |   File "<frozen importlib._bootstrap_external>", line 995, in exec_module
5|embed-fixer  |   File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
5|embed-fixer  |   File "/root/repos/embed-fixer/.venv/lib/python3.12/site-packages/aerich/__init__.py", line 20, in <module>
5|embed-fixer  |     from aerich.migrate import MIGRATE_TEMPLATE, Migrate
5|embed-fixer  |   File "/root/repos/embed-fixer/.venv/lib/python3.12/site-packages/aerich/migrate.py", line 20, in <module>
5|embed-fixer  |     from aerich.ddl import BaseDDL
5|embed-fixer  |   File "/root/repos/embed-fixer/.venv/lib/python3.12/site-packages/aerich/ddl/__init__.py", line 10, in <module>
5|embed-fixer  |     from aerich.utils import is_default_function
5|embed-fixer  |   File "/root/repos/embed-fixer/.venv/lib/python3.12/site-packages/aerich/utils.py", line 12, in <module>
5|embed-fixer  |     from anyio import from_thread
5|embed-fixer  | ModuleNotFoundError: No module named 'anyio'
5|embed-fixer  | During handling of the above exception, another exception occurred:
5|embed-fixer  | Traceback (most recent call last):
5|embed-fixer  |   File "/root/repos/embed-fixer/run.py", line 60, in <module>
5|embed-fixer  |     uvloop.run(main())
5|embed-fixer  |   File "/root/repos/embed-fixer/.venv/lib/python3.12/site-packages/uvloop/__init__.py", line 109, in run
5|embed-fixer  |     return __asyncio.run(
5|embed-fixer  |   
5|embed-fixer  |          ^^^^^^^^^^^^^^
5|embed-fixer  |   File "/root/.pyenv/versions/3.12.5/lib/python3.12/asyncio/runners.py", line 194, in run
5|embed-fixer  |     return runner.run(main)
5|embed-fixer  |   
5|embed-fixer  |          ^^^^^^^^^^^^^^^^
5|embed-fixer  |   File "/root/.pyenv/versions/3.12.5/lib/python3.12/asyncio/runners.py", line 118, in run
5|embed-fixer  |     return self._loop.run_until_complete(task)
5|embed-fixer  |       
5|embed-fixer  |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5|embed-fixer  |   File "uvloop/loop.pyx", line 1518, in uvloop.loop.Loop.run_until_complete
5|embed-fixer  |   File "/root/repos/embed-fixer/.venv/lib/python3.12/site-packages/uvloop/__init__.py", line 61, in wrapper
5|embed-fixer  |     return await main
5|embed-fixer  |            ^^^^^^^^^^
5|embed-fixer  |   File "/root/repos/embed-fixer/run.py", line 48, in main
5|embed-fixer  |     await bot.start(os.environ["DISCORD_TOKEN"])
5|embed-fixer  |   File "/root/repos/embed-fixer/.venv/lib/python3.12/site-packages/discord/client.py", line 823, in start
5|embed-fixer  |     await self.login(token)
5|embed-fixer  |   File "/root/repos/embed-fixer/.venv/lib/python3.12/site-packages/discord/client.py", line 666, in login
5|embed-fixer  |     await self.setup_hook()
5|embed-fixer  |   File "/root/repos/embed-fixer/embed_fixer/bot.py", line 84, in setup_hook
5|embed-fixer  |     await Tortoise.init(TORTOISE_CONFIG)
5|embed-fixer  |   File "/root/repos/embed-fixer/.venv/lib/python3.12/site-packages/tortoise/__init__.py", line 513, in init
5|embed-fixer  |     cls._init_apps(apps_config)
5|embed-fixer  |   File "/root/repos/embed-fixer/.venv/lib/python3.12/site-packages/tortoise/__init__.py", line 353, in _init_apps
5|embed-fixer  |     cls.init_models(info["models"], name, _init_relations=False)
5|embed-fixer  |   File "/root/repos/embed-fixer/.venv/lib/python3.12/site-packages/tortoise/__init__.py", line 334, in init_models
5|embed-fixer  |     app_models += cls._discover_models(models_path, app_label)
5|embed-fixer  |      
5|embed-fixer  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5|embed-fixer  |   File "/root/repos/embed-fixer/.venv/lib/python3.12/site-packages/tortoise/__init__.py", line 294, in _discover_models
5|embed-fixer  |     raise ConfigurationError(f'Module "{models_path}" not found')
5|embed-fixer  | tortoise.exceptions.ConfigurationError: Module "aerich.models" not found

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions