Textualize / rich

Rich is a Python library for rich text and beautiful formatting in the terminal.
https://rich.readthedocs.io/en/latest/
MIT License
49.73k stars 1.73k forks source link

[BUG] No module named 'typing_extensions' #3511

Closed vytdv closed 1 month ago

vytdv commented 1 month ago

Describe the bug

Since rich 13.9.0 has been released, when I try to upload a package with twine, I'm getting the following error:

python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.9/site-packages/twine/__main__.py", line 54, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/twine/__main__.py", line 33, in main
    error = cli.dispatch(sys.argv[1:])
  File "/usr/local/lib/python3.9/site-packages/twine/cli.py", line 121, in dispatch
    main = registered_commands[args.command].load()
  File "/usr/local/lib/python3.9/site-packages/importlib_metadata/__init__.py", line 189, in load
    module = import_module(match.group('module'))
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line [228](https://gitlab.com), in _call_with_frames_removed
  File "/usr/local/lib/python3.9/site-packages/twine/commands/upload.py", line 28, in <module>
    from twine import settings
  File "/usr/local/lib/python3.9/site-packages/twine/settings.py", line 23, in <module>
    from twine import repository
  File "/usr/local/lib/python3.9/site-packages/twine/repository.py", line 19, in <module>
    import rich.progress
  File "/usr/local/lib/python3.9/site-packages/rich/progress.py", line 45, in <module>
    from typing_extensions import Self  # pragma: no cover
ModuleNotFoundError: No module named 'typing_extensions'

When I manually install typing_extensions or when I fix rich version to 13.8.1 the problem doesn't appear.

It's pretty similar to #2979.

github-actions[bot] commented 1 month ago

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

cpnielsen commented 1 month ago

This specifically comes from this commit/change: https://github.com/Textualize/rich/commit/67e68f3722571688cab1bc569376b24231c62ba1#diff-77d13adf0fa7cbb6c2fa6adba6462b8d37e1797ab2f23229c8b6d84d7ba0fb6dR42

The project requires typing-extensions only if python < 3.9, but this change makes it a requirement for python < 3.11.

danielrbradley commented 1 month ago

cc: @willmcgugan for visibility

kajinamit commented 1 month ago

I hit the same problem via the bandit tool (the tool depends on rich). I've submitted the PR which hopefully fixes the issue and appreciate any feedback.

github-actions[bot] commented 1 month ago

I hope we solved your problem.

If you like using Rich, you might also enjoy Textual

danielrbradley commented 1 month ago

Thank you @willmcgugan for the speedy hot fix ❤️

I can confirm this has resolved our issue (using via twine).