Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circular dependency issue #545

Closed
neelasha23 opened this issue May 30, 2023 · 3 comments
Closed

Circular dependency issue #545

neelasha23 opened this issue May 30, 2023 · 3 comments
Assignees

Comments

@neelasha23
Copy link

There's a circular dependency whenever we import util.py in other modules like store.py, etc.

ImportError while loading conftest '/jupysql/src/tests/conftest.py'.
src/tests/conftest.py:8: in <module>
    from sql.magic import SqlMagic, RenderMagic
../../miniforge3/envs/jupysql/lib/python3.10/site-packages/sql/__init__.py:1: in <module>
    from .magic import RenderMagic, SqlMagic, load_ipython_extension
../../miniforge3/envs/jupysql/lib/python3.10/site-packages/sql/magic.py:22: in <module>
    import sql.connection
../../miniforge3/envs/jupysql/lib/python3.10/site-packages/sql/connection.py:11: in <module>
    from sql.store import store
../../miniforge3/envs/jupysql/lib/python3.10/site-packages/sql/store.py:10: in <module>
    from sql import util
../../miniforge3/envs/jupysql/lib/python3.10/site-packages/sql/util.py:3: in <module>
    from sql import inspect
../../miniforge3/envs/jupysql/lib/python3.10/site-packages/sql/inspect.py:4: in <module>
    from sql.connection import Connection
E   ImportError: cannot import name 'Connection' from partially initialized module 'sql.connection' (most likely due to a circular import) (/Users/neelashasen/miniforge3/envs/jupysql/lib/python3.10/site-packages/sql/connection.py)
@neelasha23 neelasha23 mentioned this issue May 30, 2023
4 tasks
@edublancas
Copy link

the cleanest way to fix this is to clean up util.py, so it doesn't have that many imports: it currently imports inspect, Connection, store. This makes util.py "difficult" to import because importing it in any of its existing imports creates the circular dependency.

so we should remove most of those imports and move that logic to a different file. essentially, we need to move out the functionality in util.py that depends on an active connection to inspect.py

@edublancas
Copy link

heads up that #654 will move things around in many files and it might impact this issue.

@yafimvo yafimvo mentioned this issue Jul 5, 2023
4 tasks
@edublancas
Copy link

fixed by #787

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants