flake8-quotes
flake8-quotes copied to clipboard
Incorrect Q003 error
Since 3.4.0 came out I am getting Q003 errors on code such as:
string = f'My id is {some_dictionary['id']}'
As per f-string changes in python 3.12 it is possible to now use the any quotes within the f-string expression without escaping first. This code was not flagging before 3.4.0. It really shouldn't be flagged given that there are no escaped inner quotes here.
Hi. You should be able to use the (default off) flag --check-inside-f-strings
to make this work.
Thanks for the quick reply.
If I enable that flag as you suggest then my Q003 error goes away, but I am now getting erroneous Q000 errors on f-strings that contain a single quote within the string.
For example, with the --check-inside-f-strings
I am getting Q000 Double quotes found but single quotes preferred
on:
string = f"Name {test_name} doesn't exist."
You are right. I have an experimental branch over at https://github.com/zheller/flake8-quotes/pull/120. I'll investigate in depth a bit later.