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

Rules B009 cause autofix error #6989

Closed
qarmin opened this issue Aug 29, 2023 · 1 comment · Fixed by #7057
Closed

Rules B009 cause autofix error #6989

qarmin opened this issue Aug 29, 2023 · 1 comment · Fixed by #7057
Labels
accepted Ready for implementation bug Something isn't working help wanted Contributions especially welcome

Comments

@qarmin
Copy link

qarmin commented Aug 29, 2023

Ruff 0.0.286 (latest changes from main branch)

ruff  *.py --select ALL,NURSERY --no-cache --fix

file content:

print(getattr(1, "real"))

error:

error: Autofix introduced a syntax error. Reverting all changes.

This indicates a bug in `ruff`. If you could open an issue at:

    https://github.com/astral-sh/ruff/issues/new?title=%5BAutofix%20error%5D

...quoting the contents of `Attributes3841.py`, the rule codes B009, along with the `pyproject.toml` settings and executed command, we'd be very appreciative!

Attributes3841.py:1:1: T201 `print` found
Attributes3841.py:1:1: D100 Missing docstring in public module
Attributes3841.py:1:1: CPY001 Missing copyright notice at top of file
Attributes3841.py:1:7: B009 Do not call `getattr` with a constant attribute value. It is not any safer than normal property access.

Attributes3841.py.zip

@zanieb
Copy link
Member

zanieb commented Aug 29, 2023

Similar to #6792 / #6788 this is fixed to print(1.real) and we'll need to special case integers.

@zanieb zanieb added bug Something isn't working help wanted Contributions especially welcome accepted Ready for implementation labels Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation bug Something isn't working help wanted Contributions especially welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants