safety icon indicating copy to clipboard operation
safety copied to clipboard

AttributeError: module 'typer' has no attribute 'rich_utils'

Open brent-cybrid opened this issue 1 year ago • 2 comments

Checklist

Safety version

3.6.1

Python version

3.13.3

Operating System

macOS

Describe the problem you'd like to have solved

Traceback (most recent call last):
  File "<virtualenv directory>/bin/safety", line 5, in <module>
    from safety.cli import cli
  File "<virtualenv directory>/lib/python3.13/site-packages/safety/cli.py", line 724, in <module>
    typer.rich_utils.STYLE_HELPTEXT = ""
    ^^^^^^^^^^^^^^^^
AttributeError: module 'typer' has no attribute 'rich_utils'

Describe the ideal solution

The safety CLI would execute without error

Alternatives and current workarounds

Revert typer back to version < 0.17.0

Additional context

No response

What I Did

Traceback (most recent call last):
  File "<virtualenv directory>/bin/safety", line 5, in <module>
    from safety.cli import cli
  File "<virtualenv directory>/lib/python3.13/site-packages/safety/cli.py", line 724, in <module>
    typer.rich_utils.STYLE_HELPTEXT = ""
    ^^^^^^^^^^^^^^^^
AttributeError: module 'typer' has no attribute 'rich_utils'

brent-cybrid avatar Sep 02 '25 11:09 brent-cybrid

Hi @brent-cybrid, thank you for opening this issue!

We appreciate your effort in reporting this. Our team will review it and get back to you soon. If you have any additional details or updates, feel free to add them to this issue.

Note: If this is a serious security issue that could impact the security of Safety CLI users, please email [email protected] immediately.

Thank you for contributing to Safety CLI!

github-actions[bot] avatar Sep 02 '25 11:09 github-actions[bot]

Note for others having this issue: The issue seems to stem from the fact that safety's dependency on typer: https://github.com/pyupio/safety/blob/37883d49b74e53acb7928280bed1440312241dbc/pyproject.toml#L49

typer 17.0 introduced a change where the attribute being complained about is lazy-loaded, which is why this is breaking.

You can work around the issue by restricting typer to typer~=16.0.0 in your own project.

The fix for the safety maintainers is one of the following:

  1. restrict typer as shown in the workaround above
  2. Update usage of typer s.t this error no longer occurs.

totternessZB avatar Feb 04 '26 17:02 totternessZB