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

Q000, Q001, Q002 can't be ignored in Ruff 0.3.5 #10724

Closed
hinohi opened this issue Apr 2, 2024 · 4 comments · Fixed by #10728
Closed

Q000, Q001, Q002 can't be ignored in Ruff 0.3.5 #10724

hinohi opened this issue Apr 2, 2024 · 4 comments · Fixed by #10728
Assignees
Labels
bug Something isn't working

Comments

@hinohi
Copy link

hinohi commented Apr 2, 2024

In Ruff 0.3.5, if specifying to ignore one or two of the Q000, Q001, Q002 rules, they are not ignored.
However, if specifying to ignore all three of those rules, then it works as expected.

Reproduction code:

'''
bad docsting
'''
a = 'single'
b = '''
bad multi line
'''

Running:

ruff check . --isolated --select Q --ignore Q000
ruff check . --isolated --select Q --ignore Q001
ruff check . --isolated --select Q --ignore Q002
ruff check . --isolated --select Q --ignore Q000,Q001
ruff check . --isolated --select Q --ignore Q000,Q002
ruff check . --isolated --select Q --ignore Q001,Q002

Output is:

a.py:1:1: Q002 [*] Single quote docstring found but double quotes preferred
a.py:4:5: Q000 Single quotes found but double quotes preferred
a.py:5:5: Q001 [*] Single quote multiline found but double quotes preferred
Found 3 errors.
[*] 2 fixable with the `--fix` option.

If specifying to ignore all three of those rules, then it works as expected:

$ ruff check . --isolated --select Q --ignore Q000,Q001,Q002
All checks passed!
  • In 0.3.4, it correctly shows All checks passed!.
  • I've tested this with Python versions 3.12.0 and 3.9.18, and the behavior is the same on both.
  • I've observed this on both macOS 13.6 and Ubuntu 22.04.
  • The issue persists whether configuring via the pyproject.toml file or command line arguments.

Please let me know if you need any clarification or have additional details to provide.

@hinohi hinohi changed the title ignore Q000x not working in Ruff 0.3.5 ignore Q00x not working in Ruff 0.3.5 Apr 2, 2024
@averykhoo
Copy link

averykhoo commented Apr 2, 2024

+1, facing the same issue

my ruff.toml includes:

[lint]
select = [
    ...
    "Q", # flake8-quotes
    ...
]
ignore = [
    ...
    "Q000", # don't be pedantic about 'string' / "string"
    "Q001", # don't be pedantic about '''string''' / """string"""
    ...
]

@averykhoo
Copy link

averykhoo commented Apr 2, 2024

was testing the config, the following flags Q000 when it clearly shouldn't:

[lint]
select = [
    "Q002", # flake8-quotes:bad-quotes-docstring
]

but the following doesn't flag Q000

[lint]
select = [
    ...
    #"Q", # flake8-quotes
    "Q000",
    "Q001",
    "Q003",
    "Q004",
    ...
]
ignore = [
    ...
    "Q000", # don't be pedantic about 'string' / "string"
    "Q001", # don't be pedantic about '''string''' / """string"""
    ...
]

so it doesn't seem to be a problem with ignore, just with Q002 specifically

hope this helps you narrow down the issue!

@charliermarsh charliermarsh self-assigned this Apr 2, 2024
@charliermarsh charliermarsh added the bug Something isn't working label Apr 2, 2024
@charliermarsh
Copy link
Member

I think it's just an oversight in where we apply the ignores for those rules. I'll fix it now. Thanks!

charliermarsh added a commit that referenced this issue Apr 2, 2024
## Summary

We lost the per-rule ignores when these were migrated to the AST, so if
_any_ `Q` rule is enabled, they're now all enabled.

Closes #10724.

## Test Plan

Ran:

```shell
ruff check . --isolated --select Q --ignore Q000
ruff check . --isolated --select Q --ignore Q001
ruff check . --isolated --select Q --ignore Q002
ruff check . --isolated --select Q --ignore Q000,Q001
ruff check . --isolated --select Q --ignore Q000,Q002
ruff check . --isolated --select Q --ignore Q001,Q002
```

...against:

```python
'''
bad docsting
'''
a = 'single'
b = '''
bad multi line
'''
```
@charliermarsh
Copy link
Member

Fixed in the next release, sorry about that.

This was referenced Apr 3, 2024
@AlexWaygood AlexWaygood changed the title ignore Q00x not working in Ruff 0.3.5 Q000, Q001, Q002 can't be ignored in Ruff 0.3.5 Apr 4, 2024
@AlexWaygood AlexWaygood pinned this issue Apr 4, 2024
@charliermarsh charliermarsh unpinned this issue Apr 5, 2024
dalcinl added a commit to mpi4py/mpi4py that referenced this issue Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants