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 breaking httpie.output.formatters.colors import #925

Closed
bsolomon1124 opened this issue May 26, 2020 · 1 comment
Closed

Comments

@bsolomon1124
Copy link
Contributor

bsolomon1124 commented May 26, 2020

httpie/httpie/output/formatters/colors.py imports from from httpie.plugins, which imports ColorFormatter, and so on ...

Python 3.8 output:

$ python -m pip install -U pip wheel setuptools pygments httpie
$ python
Python 3.8.3 (default, May 19 2020, 21:34:17) 
[Clang 11.0.0 (clang-1100.0.33.12)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from httpie.output.formatters.colors import get_lexer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/brad/Scripts/python/envs/venv/lib/python3.8/site-packages/httpie/output/formatters/colors.py", line 20, in <module>
    from httpie.plugins import FormatterPlugin
  File "/Users/brad/Scripts/python/envs/venv/lib/python3.8/site-packages/httpie/plugins/__init__.py", line 14, in <module>
    from httpie.output.formatters.colors import ColorFormatter
ImportError: cannot import name 'ColorFormatter' from partially initialized module 'httpie.output.formatters.colors' (most likely due to a circular import) (/Users/brad/Scripts/python/envs/venv/lib/python3.8/site-packages/httpie/output/formatters/colors.py)

3.7:

$ python
Python 3.7.7 (default, Apr  9 2020, 18:09:52) 
[Clang 11.0.0 (clang-1100.0.33.12)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from httpie.output.formatters.colors import get_lexer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/brad/Scripts/python/envs/venv/lib/python3.7/site-packages/httpie/output/formatters/colors.py", line 20, in <module>
    from httpie.plugins import FormatterPlugin
  File "/Users/brad/Scripts/python/envs/venv/lib/python3.7/site-packages/httpie/plugins/__init__.py", line 14, in <module>
    from httpie.output.formatters.colors import ColorFormatter
ImportError: cannot import name 'ColorFormatter' from 'httpie.output.formatters.colors' (/Users/brad/Scripts/python/envs/venv/lib/python3.7/site-packages/httpie/output/formatters/colors.py)

Which can be addressed with this hack:

>>> from httpie.plugins import *
>>> from httpie.output.formatters.colors import get_lexer
@jkbrzt jkbrzt closed this as completed in cd085cb May 26, 2020
@jkbrzt
Copy link
Member

jkbrzt commented May 26, 2020

Fixed, thanks!

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