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
Respect py-version for inconsistent-quotes
inside f-strings
#9152
Respect py-version for inconsistent-quotes
inside f-strings
#9152
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #9152 +/- ##
=======================================
Coverage 95.76% 95.76%
=======================================
Files 173 173
Lines 18680 18690 +10
=======================================
+ Hits 17889 17899 +10
Misses 791 791
|
This comment has been minimized.
This comment has been minimized.
Despite ``sys.version`` check, pylint raises the warning with Python 3.11
π€ According to the primer, this change has no effect on the checked open source code. π€π This comment was generated for commit 720de79 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great contribution. Maybe the following could be added in the message definition: {"maxversion": (3, 12)},
(see
pylint/pylint/checkers/async.py
Line 31 in 0796dfa
{"minversion": (3, 5)}, |
if self.minversion is not None and self.minversion > py_version: |
Thank you! I am not sure if we can add a version limit to the message "W1405 inconsistent-quotes" definition itself because this PR addresses only differences with f-strings handling. Other problems with inconsistent quotes are not related to Python version so they cannot be dispatched from message definition. Maybe if we have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm you're right, probably not worth the very small perf/maintance improvment then.
* [inconsistent-quotes] Emit for f-strings for 3.12 only * Add docs for inconsistent-quotes with f-strings Despite ``sys.version`` check, pylint raises the warning with Python 3.11 (cherry picked from commit 1c0bc70)
Type of Changes
Description
When running pre-3.12 interpeter, f-strings are opaque and are represented as a STRING token (like 'f'{dictionary["0"]}' for the test case in the ticket). So they are not used in analysis.
With 3.12 PEG interpreter, f-string is a proper Python expression, even if we target pre-3.12. So this PR enables
inconsistent-quotes
checks for string literals only if a target version is 3.12 or later.Closes #9113