-
Notifications
You must be signed in to change notification settings - Fork 944
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
Include some of the checks from flake8-literal #8616
Comments
My first impression is that some of these feel redundant with existing rules, e.g., "Use double quotes for docstring" exists in the I do consider this low priority since the formatter already performs this normalization and removes unnecessary escapes, but I'd accept a contribution for such a rule in the `Q set. |
@ThiefMaster - Anything else you want to include here, or is the string-escaping sufficient to close? |
That was the main one I was interested in. These ones at least sound interesting:
This code currently triggers a warning in flake8-quotes but not in ruff (with single-quote preference): foo = (
"i'm"
"really" # <-- does not need double quotes
'cool'
) But probably this could be a setting that affects the existing Q000 rule (whether consistency for continuation strings should be preferred, avoided or ignored).
There are no rules for this yet. Could be a nice one to add.
There is no rule for this one yet. It's pretty common to always use raw strings for regexps regardless whether there are any escapes in it or not (but it's particularly useful when there are escapes!), so at least for those passed directly as literals to the various functions from the |
This plugin is quite similar than
flake8-quotes
, but it contains some nice checks such as warning about unnecessary quote escapes, e.g.'foo\"bar'
(which, in fact, are created by ruff's fixer - I've opened a separate issue about this: #8617)..flake8
config:ruff.toml
configPython code:
flake8 output:
ruff output (built from latest master):
In particular it would be nice if anything related to avoid escaping would actually pick the quote style to ensure the least amount of escapes (in case the string contains both types of quotes). Maybe even consider switching to a triple-quoted string, but maybe that's a bit more controversial and should be configurable...
The text was updated successfully, but these errors were encountered: