-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Respect py-version for
inconsistent-quotes
inside f-strings (#9152)…
… (#9155) * [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) Co-authored-by: theirix <[email protected]>
- Loading branch information
1 parent
a9d9dc3
commit a77f0c1
Showing
9 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Emit ``inconsistent-quotes`` for f-strings with 3.12 interpreter only if targeting pre-3.12 versions. | ||
|
||
Closes #9113 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
tests/functional/i/inconsistent/inconsistent_quotes_fstring.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# pylint: disable=missing-module-docstring | ||
|
||
dictionary = {'0': 0} | ||
f_string = f'{dictionary["0"]}' |
5 changes: 5 additions & 0 deletions
5
tests/functional/i/inconsistent/inconsistent_quotes_fstring.rc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[STRING] | ||
check-quote-consistency=yes | ||
|
||
[testoptions] | ||
max_pyver=3.12 |
5 changes: 5 additions & 0 deletions
5
tests/functional/i/inconsistent/inconsistent_quotes_fstring_py312.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# pylint: disable=missing-module-docstring | ||
|
||
dictionary = {'0': 0} | ||
# quotes are inconsistent when targetting Python 3.12 (use single quotes) | ||
f_string = f'{dictionary["0"]}' # [inconsistent-quotes] |
8 changes: 8 additions & 0 deletions
8
tests/functional/i/inconsistent/inconsistent_quotes_fstring_py312.rc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[STRING] | ||
check-quote-consistency=yes | ||
|
||
[main] | ||
py-version=3.12 | ||
|
||
[testoptions] | ||
min_pyver=3.12 |
1 change: 1 addition & 0 deletions
1
tests/functional/i/inconsistent/inconsistent_quotes_fstring_py312.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
inconsistent-quotes:5:0:None:None::"Quote delimiter "" is inconsistent with the rest of the file":UNDEFINED |
5 changes: 5 additions & 0 deletions
5
tests/functional/i/inconsistent/inconsistent_quotes_fstring_py312_311.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# pylint: disable=missing-module-docstring | ||
|
||
dictionary = {'0': 0} | ||
# quotes are consistent when targetting 3.11 and earlier (cannot use single quotes here) | ||
f_string = f'{dictionary["0"]}' |
8 changes: 8 additions & 0 deletions
8
tests/functional/i/inconsistent/inconsistent_quotes_fstring_py312_311.rc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[STRING] | ||
check-quote-consistency=yes | ||
|
||
[main] | ||
py-version=3.11 | ||
|
||
[testoptions] | ||
min_pyver=3.12 |