AttributeError: module 'typer' has no attribute 'rich_utils'
Checklist
- [x] I agree to the terms within the Safety Code of Conduct.
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'
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!
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:
- restrict
typeras shown in the workaround above - Update usage of
typers.t this error no longer occurs.