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 import #120

Open
abtinmo opened this issue May 29, 2023 · 5 comments
Open

circular import #120

abtinmo opened this issue May 29, 2023 · 5 comments

Comments

@abtinmo
Copy link

abtinmo commented May 29, 2023

I installed the package on a freshly created environment and the first import raises an import error.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/User/Programming/functional/.venv/lib/python3.9/site-packages/pfun/__init__.py", line 5, in <module>
    from . import clock, console, files, logging, random, state, subprocess  # noqa
  File "/Users/User/Programming/functional/.venv/lib/python3.9/site-packages/pfun/clock.py", line 6, in <module>
    from . import effect
ImportError: cannot import name 'effect' from partially initialized module 'pfun' (most likely due to a circular import) (/Users/User/Programming/functional/.venv/lib/python3.9/site-packages/pfun/__init__.py)
>>> ```
@suned
Copy link
Owner

suned commented Jun 7, 2023

Can you share what you were importing? I can't immediately reproduce this.

@abtinmo
Copy link
Author

abtinmo commented Jun 8, 2023

os: macos, fedora 38
python versions: 3.11, 3.9

my steps to reproduce the bug:

creating new env:

➜  python3 -m virtualenv .venv
created virtual environment CPython3.11.3.final.0-64 in 187ms
  creator CPython3Posix(dest=/Users/User/Programming/functional/.venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/User/Library/Application Support/virtualenv)
    added seed packages: pip==23.1.2, setuptools==67.7.2, wheel==0.40.0
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

activating it

➜ source .venv/bin/activate

installing the package

(.venv) ➜ pip install pfun 
Collecting pfun
  Using cached pfun-0.13.0-cp311-cp311-macosx_13_0_arm64.whl
Collecting dill<0.4.0,>=0.3.2 (from pfun)
  Using cached dill-0.3.6-py3-none-any.whl (110 kB)
Collecting typing-extensions<4.0.0.0,>=3.10.0.0 (from pfun)
  Using cached typing_extensions-3.10.0.2-py3-none-any.whl (26 kB)
Installing collected packages: typing-extensions, dill, pfun
Successfully installed dill-0.3.6 pfun-0.13.0 typing-extensions-3.10.0.2

running a python shell and importing the curry decorator

(.venv) ➜ python3                         
Python 3.11.3 (main, Apr  7 2023, 20:13:31) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pfun.functions import curry
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/User/Programming/functional/.venv/lib/python3.11/site-packages/pfun/__init__.py", line 5, in <module>
    from . import clock, console, files, logging, random, state, subprocess  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/User/Programming/functional/.venv/lib/python3.11/site-packages/pfun/clock.py", line 6, in <module>
    from . import effect
ImportError: cannot import name 'effect' from partially initialized module 'pfun' (most likely due to a circular import) (/Users/User/Programming/functional/.venv/lib/python3.11/site-packages/pfun/__init__.py)
>>> 

@suned
Copy link
Owner

suned commented Jul 30, 2023

Thank you! I'll investigate

@sdaves
Copy link
Contributor

sdaves commented Nov 1, 2023

@suned Any update on this issue?

@sdaves
Copy link
Contributor

sdaves commented Nov 14, 2023

@suned @abtinmo This is fixed with my pr #125

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

3 participants