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

Consider respecting avoid-escape when enforcing other flake8-quotes rules #7889

Open
BT-rmartin opened this issue Oct 10, 2023 · 9 comments
Open
Labels
bug Something isn't working

Comments

@BT-rmartin
Copy link

BT-rmartin commented Oct 10, 2023

My Ruff version is 0.0.292
My configuration of Ruff is

[tool.ruff]
select = ["E", "F", "I", "PL", "B", "Q", "D", "N", "S", "G", "RUF", "W"]
ignore = ["D100", "D101", "D104", "D213", "D203", "RUF012"]
exclude = ["**/ext/"]

line-length = 115

[tool.ruff.per-file-ignores]
"__init__.py" = ["F401"]
"__manifest__.py" = ["B018"]
"**/tests/*.py" = ["S101"]

[tool.ruff.flake8-quotes]
docstring-quotes = "double"
inline-quotes = "single"
multiline-quotes = "double"
avoid-escape = false

I had a file like this

{
    "name": "My module",
    "version": "16.0.1.0.0",
    "summary": "Strips newline from text's fields",
    "category": "Accounting",
    "installable": True,
}

When running ruff . --fix, it produces a file like this, which is mixing up single quote and double quote in the summary key due to the apostrophe it had there

{
    'name': 'My module',
    'version': '16.0.1.0.0',
    'summary': "Strips newline from text's fields",
    'category': 'Accounting',
    'installable': True,
}

I would expect that it's able to escape the apostrophe as I have avoid-escape = false.
Could you please tell me what is wrong here?

Anothe working option for me would be to ignore the flake8-quotes for specific files. Is that possible?

Thanks in advance

@charliermarsh charliermarsh added the bug Something isn't working label Oct 10, 2023
@charliermarsh
Copy link
Member

I think this is a bug because we aren't respecting avoid-escape = false in all of the Q rules.

@BT-rmartin
Copy link
Author

@charliermarsh Thanks for the quick answer.
When do you estimate this might be fixed?

@charliermarsh
Copy link
Member

I would guess in the next week or two?

@dhruvmanila
Copy link
Member

I think this is a bug because we aren't respecting avoid-escape = false in all of the Q rules.

That's true although flake8-quotes has the same behavior:

flake8 t.py --no-avoid-escape  

Maybe related #2400

@charliermarsh charliermarsh changed the title Bug with tool.ruff.flake8-quotes configuration Consider respecting avoid-escape when enforcing other flake8-quotes rules Oct 14, 2023
@BT-rmartin
Copy link
Author

@charliermarsh Any progress on this topic?

@dhruvmanila
Copy link
Member

I'm sorry there hasn't been any progress here but we might want to hold off until #7927 is finalized and merged as that could simplify the implementation of flake8-quotes rules.

@BT-rmartin
Copy link
Author

Ok thanks @dhruvmanila. When do you estimate this could be done?

@BT-rmartin
Copy link
Author

hi @dhruvmanila, @charliermarsh When do you estimate this might be fixed?

@zanieb
Copy link
Member

zanieb commented Nov 19, 2023

@BT-rmartin please do not bump issues repeatedly. #7927 is still in-progress. Updates will be posted here when progress is made on this issue.

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

No branches or pull requests

4 participants