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

[BUG] ModuleNotFoundError when importing rich.markdown #2979

Closed
2 tasks done
mcdonnnj opened this issue May 31, 2023 · 7 comments
Closed
2 tasks done

[BUG] ModuleNotFoundError when importing rich.markdown #2979

mcdonnnj opened this issue May 31, 2023 · 7 comments

Comments

@mcdonnnj
Copy link

mcdonnnj commented May 31, 2023

Describe the bug

I ran into this issue in a dependent projects (ansible-lint), but I believe this bug was introduced in #2977 and pushed out with v13.4.0. A package dependency was incorrectly implemented which results in failure when this package is used with Markdown.

Click to expand

I see the following error in ansible-lint:

  File "/home/mcdonnnj/.pyenv/versions/python_testing/lib/python3.11/site-packages/ansiblelint/color.py", line 7, in <module>
    import rich.markdown
  File "/home/mcdonnnj/.pyenv/versions/python_testing/lib/python3.11/site-packages/rich/markdown.py", line 7, in <module>
    from typing_extensions import get_args
ModuleNotFoundError: No module named 'typing_extensions'

This is because

from typing_extensions import get_args
does not import as is done elsewhere in this project such as

rich/rich/emoji.py

Lines 10 to 13 in cf13882

if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal # pragma: no cover
and because typing_extensions is only installed if Python <3.8 per
typing_extensions = {version = ">=3.7.4", markers = "python_version < \"3.8\""}

I could be mistaken but that seems to be the most likely cause of this failure.

@github-actions
Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@aroberts87
Copy link

Hey, I'm also hitting this issue when running ansible-lint. Glad to know it's not just me. 😅

 Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.3/x64/bin/ansible-lint", line 5, in <module>
    from ansiblelint.__main__ import _run_cli_entrypoint
  File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/ansiblelint/__main__.py", line 39, in <module>
    from ansiblelint import cli
  File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/ansiblelint/cli.py", line 29, in <module>
    from ansiblelint.yaml_utils import clean_json
  File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/ansiblelint/yaml_utils.py", line 32, in <module>
    from ansiblelint.utils import Task
  File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/ansiblelint/utils.py", line 56, in <module>
    from ansiblelint.app import get_app
  File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/ansiblelint/app.py", line 17, in <module>
    from ansiblelint.color import console, console_stderr, render_yaml
  File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/ansiblelint/color.py", line 7, in <module>
    import rich.markdown
  File "/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/rich/markdown.py", line 7, in <module>
    from typing_extensions import get_args
ModuleNotFoundError: No module named 'typing_extensions'

@mcdonnnj
Copy link
Author

Yeah it looks like a fix is already on the way per 1176f81.

@willmcgugan
Copy link
Collaborator

Please try v13.4.1

@aroberts87
Copy link

Works like a charm for me, @willmcgugan! Thanks!

@mcdonnnj
Copy link
Author

@willmcgugan After updating I no longer see the failure when running ansible-lint, thanks for the fast turnaround!

@github-actions
Copy link

I hope we solved your problem.

If you like using Rich, you might also enjoy Textual

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

No branches or pull requests

3 participants