-
Notifications
You must be signed in to change notification settings - Fork 39
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 error on f-string for CPython 3.12 #117
Comments
This has to do with the change in f-string behavior (adoption of a formal grammar) in Python 3.12 -- now each There are two issues that arise from this:
So an option to disable checking inside f-strings would be most helpful for either or both of these reasons. Thank you! |
In a way, this addresses zheller/flake8-quotes#117, since it forces the Python that runs flake8 onto 'oldest supported', currently 3.8.
In a way, this addresses zheller/flake8-quotes#117, since it forces the Python that runs flake8 onto 'oldest supported', currently 3.8.
These double quotes raise the Q000 error with python 3.12 and higher. However, using single quotes here would break support for python 3.11 and lower. See: zheller/flake8-quotes#117
Please make this configurable, e.g. by using a separate error code for quotes inside fstrings. Because even on a 3.12-only codebase one may prefer to NOT use the same type of quotes simple for the sake of readability and being nice towards editors whose syntax highlighting may not properly handle reusing the same quotes. |
@JoeHitchen or @zheller (since you are the maintainers who can actually make a new release besides @twolfson who stepped down according to another issue): Any chance of this being fixed? Or at least a bugfix release being done if someone sends a PR to fix it? |
Hi - Yes, if there is a pull request that fixes the problem and passes the tests then I can cast an eye over it and make a release. |
I quickly hacked together a POC at #118, the state-machine tracking the nesting depth of f-strings is simple enough, I'll see how far I can take it this weekend |
@JoeHitchen I have a preliminary version which passes (when run manually on my local machine) for Python 3.11 and 3.12. The fix is not backwards compatible though, there are positives in 3.12, which weren't there in 3.11, and guidance on that point would be appreciated. |
We wouldn't want to break backwards compatibility, but is there a way to inspect the python version before deciding to apply the new rule or not? |
@JoeHitchen I've built a simple test harness using (BTW: I've not managed to test this successfully on Python 3.4/3.5, perhaps its time to drop support for those, 3.5 was EOLed in 2020) |
IMHO anything that's EOL, ie <=3.7 should be removed. Someone using such an obsolete Python version can just use an old version of this package... +1 on GH actions. Might also want to switch to pytest at some point since the current test runner is awful (in fact when I started working on this same thing yesterday before I saw you already being on it, it was quite easy to run even the existing tests using |
I'd be happy to accept a PR to master which works for >=3.6 but drops 3.4 & 3.5. A release which formally drops 3.4 & 3.5 make take a bit longer as we probably need to tidy up some other bits (e.g. documentation) to reflect that change, but it will be installable from the repo for those that want it sooner. Also agree that Github Actions would help test compatibility with different versions python versions. |
An example:
No errors from the plugin on the CPython 3.11:
While on the CPython 3.12 I got this error:
a.py:3:12: Q000 Double quotes found but single quotes preferred
.The text was updated successfully, but these errors were encountered: