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

Incorrect Q003 error #119

Open
jonyscathe opened this issue Feb 14, 2024 · 4 comments
Open

Incorrect Q003 error #119

jonyscathe opened this issue Feb 14, 2024 · 4 comments

Comments

@jonyscathe
Copy link

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.

@arnimarj
Copy link
Contributor

Hi. You should be able to use the (default off) flag --check-inside-f-strings to make this work.

@jonyscathe
Copy link
Author

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."

@arnimarj arnimarj mentioned this issue Feb 15, 2024
@arnimarj
Copy link
Contributor

You are right. I have an experimental branch over at #120. I'll investigate in depth a bit later.

@rtb-zla-karma
Copy link

Hello.

I'm getting the same error for code

item_text = "hello"
x = f'{{"text": "{item_text}"}}'

Message:

x = f'{{"text": "{item_text}"}}'
    ^
1     Q000 Single quotes found but double quotes preferred

I have to ignore it through # noqa: Q000.

Env:

Python 3.12.2
flake8==7.0.0
flake8-quotes==3.4.0

Config:

inline-quotes = "
multiline-quotes = """
docstring-quotes = """
avoid-escape = True
check-inside-f-strings = True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants