-
-
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.
Add unsupported version checks for Python 3.8+ syntax
- Loading branch information
1 parent
2d484f5
commit 153da4b
Showing
27 changed files
with
151 additions
and
48 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
doc/data/messages/u/using-assignment-expression-in-unsupported-version/bad.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 @@ | ||
import random | ||
|
||
# +1 : [using-assignment-expression-in-unsupported-version] | ||
if zero_or_one := random.randint(0, 1): | ||
assert zero_or_one == 1 |
1 change: 1 addition & 0 deletions
1
doc/data/messages/u/using-assignment-expression-in-unsupported-version/details.rst
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 @@ | ||
The assignment expression (walrus) operator (`:=`) was introduced in Python 3.8; to use it, please use a more recent version of Python. |
5 changes: 5 additions & 0 deletions
5
doc/data/messages/u/using-assignment-expression-in-unsupported-version/good.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 @@ | ||
import random | ||
|
||
zero_or_one = random.randint(0, 1) | ||
if zero_or_one: | ||
assert zero_or_one == 1 |
2 changes: 2 additions & 0 deletions
2
doc/data/messages/u/using-assignment-expression-in-unsupported-version/pylintrc
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,2 @@ | ||
[main] | ||
py-version=3.7 |
2 changes: 2 additions & 0 deletions
2
doc/data/messages/u/using-positional-only-args-in-unsupported-version/bad.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,2 @@ | ||
def add(x, y, /): # [using-positional-only-args-in-unsupported-version] | ||
return x + y |
1 change: 1 addition & 0 deletions
1
doc/data/messages/u/using-positional-only-args-in-unsupported-version/details.rst
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 @@ | ||
Positional-only arguments were introduced in Python 3.8; to use them, please use a more recent version of Python. |
3 changes: 3 additions & 0 deletions
3
doc/data/messages/u/using-positional-only-args-in-unsupported-version/good.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,3 @@ | ||
# pylint: disable=missing-function-docstring, missing-module-docstring | ||
def add(x, y): | ||
return x + y |
2 changes: 2 additions & 0 deletions
2
doc/data/messages/u/using-positional-only-args-in-unsupported-version/pylintrc
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,2 @@ | ||
[main] | ||
py-version=3.7 |
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
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
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 @@ | ||
Add `using-assignment-expression-in-unsupported-version` for uses of `:=` (walrus operator) | ||
on Python versions below 3.8 provided with `--py-version`. | ||
|
||
Closes #9820 |
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 @@ | ||
Add `using-positional-only-args-in-unsupported-version` for uses of positional-only args on | ||
Python versions below 3.8 provided with `--py-version`. | ||
|
||
Closes #9823 |
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
6 changes: 3 additions & 3 deletions
6
tests/functional/b/broad_exception/broad_exception_caught.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
broad-exception-caught:14:7:14:16::Catching too general exception Exception:INFERENCE | ||
broad-exception-caught:20:7:20:20::Catching too general exception BaseException:INFERENCE | ||
broad-exception-caught:32:7:32:27::Catching too general exception CustomBroadException:INFERENCE | ||
broad-exception-caught:14:7:14:16::Catching too general exception Exception:INFERENCE | ||
broad-exception-caught:20:7:20:20::Catching too general exception BaseException:INFERENCE | ||
broad-exception-caught:32:7:32:27::Catching too general exception CustomBroadException:INFERENCE |
6 changes: 3 additions & 3 deletions
6
tests/functional/b/broad_exception/broad_exception_caught_trystar.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
broad-exception-caught:14:8:14:17::Catching too general exception Exception:INFERENCE | ||
broad-exception-caught:20:8:20:21::Catching too general exception BaseException:INFERENCE | ||
broad-exception-caught:32:7:32:27::Catching too general exception CustomBroadException:INFERENCE | ||
broad-exception-caught:14:8:14:17::Catching too general exception Exception:INFERENCE | ||
broad-exception-caught:20:8:20:21::Catching too general exception BaseException:INFERENCE | ||
broad-exception-caught:32:7:32:27::Catching too general exception CustomBroadException:INFERENCE |
16 changes: 8 additions & 8 deletions
16
tests/functional/b/broad_exception/broad_exception_raised.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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
broad-exception-raised:15:4:15:41:exploding_apple:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:20:8:20:34:raise_and_catch:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-caught:21:11:21:20:raise_and_catch:Catching too general exception Exception:INFERENCE | ||
broad-exception-raised:38:8:38:35:raise_catch_raise:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:46:8:46:40:raise_catch_raise_using_alias:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:48:0:48:17::"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:49:0:49:21::"Raising too general exception: BaseException":INFERENCE | ||
broad-exception-raised:50:0:50:28::"Raising too general exception: CustomBroadException":INFERENCE | ||
broad-exception-raised:15:4:15:41:exploding_apple:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:20:8:20:34:raise_and_catch:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-caught:21:11:21:20:raise_and_catch:Catching too general exception Exception:INFERENCE | ||
broad-exception-raised:38:8:38:35:raise_catch_raise:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:46:8:46:40:raise_catch_raise_using_alias:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:48:0:48:17::"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:49:0:49:21::"Raising too general exception: BaseException":INFERENCE | ||
broad-exception-raised:50:0:50:28::"Raising too general exception: CustomBroadException":INFERENCE |
16 changes: 8 additions & 8 deletions
16
tests/functional/b/broad_exception/broad_exception_raised_trystar.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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
broad-exception-raised:15:4:15:41:exploding_apple:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:20:8:20:34:raise_and_catch_star:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-caught:21:12:21:21:raise_and_catch_star:Catching too general exception Exception:INFERENCE | ||
broad-exception-raised:38:8:38:35:raise_catch_raise_star:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:46:8:46:40:raise_catch_raise_using_alias_star:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:48:0:48:17::"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:49:0:49:21::"Raising too general exception: BaseException":INFERENCE | ||
broad-exception-raised:50:0:50:28::"Raising too general exception: CustomBroadException":INFERENCE | ||
broad-exception-raised:15:4:15:41:exploding_apple:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:20:8:20:34:raise_and_catch_star:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-caught:21:12:21:21:raise_and_catch_star:Catching too general exception Exception:INFERENCE | ||
broad-exception-raised:38:8:38:35:raise_catch_raise_star:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:46:8:46:40:raise_catch_raise_using_alias_star:"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:48:0:48:17::"Raising too general exception: Exception":INFERENCE | ||
broad-exception-raised:49:0:49:21::"Raising too general exception: BaseException":INFERENCE | ||
broad-exception-raised:50:0:50:28::"Raising too general exception: CustomBroadException":INFERENCE |
4 changes: 4 additions & 0 deletions
4
tests/functional/u/unsupported/unsupported_version_for_assignment_expression.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-function-docstring, missing-module-docstring | ||
import random | ||
if (zero_or_one := random.randint(0, 1)): # [using-assignment-expression-in-unsupported-version] | ||
assert zero_or_one == 1 |
2 changes: 2 additions & 0 deletions
2
tests/functional/u/unsupported/unsupported_version_for_assignment_expression.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,2 @@ | ||
[main] | ||
py-version=3.7 |
1 change: 1 addition & 0 deletions
1
tests/functional/u/unsupported/unsupported_version_for_assignment_expression.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 @@ | ||
using-assignment-expression-in-unsupported-version:3:4:3:39::Assignment expression (walrus operator) is not supported by all versions included in the py-version setting:HIGH |
6 changes: 3 additions & 3 deletions
6
tests/functional/u/unsupported/unsupported_version_for_exception_group.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
using-exception-groups-in-unsupported-version:5:4:5:53:f:Exception groups are not supported by all versions included in the py-version setting:UNDEFINED | ||
using-exception-groups-in-unsupported-version:8:0:13:36::Exception groups are not supported by all versions included in the py-version setting:UNDEFINED | ||
using-exception-groups-in-unsupported-version:18:0:21:29::Exception groups are not supported by all versions included in the py-version setting:UNDEFINED | ||
using-exception-groups-in-unsupported-version:5:4:5:53:f:Exception groups are not supported by all versions included in the py-version setting:HIGH | ||
using-exception-groups-in-unsupported-version:8:0:13:36::Exception groups are not supported by all versions included in the py-version setting:HIGH | ||
using-exception-groups-in-unsupported-version:18:0:21:29::Exception groups are not supported by all versions included in the py-version setting:HIGH |
4 changes: 2 additions & 2 deletions
4
tests/functional/u/unsupported/unsupported_version_for_f_string.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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
using-f-string-in-unsupported-version:4:6:4:26::F-strings are not supported by all versions included in the py-version setting:UNDEFINED | ||
using-f-string-in-unsupported-version:5:10:5:53::F-strings are not supported by all versions included in the py-version setting:UNDEFINED | ||
using-f-string-in-unsupported-version:4:6:4:26::F-strings are not supported by all versions included in the py-version setting:HIGH | ||
using-f-string-in-unsupported-version:5:10:5:53::F-strings are not supported by all versions included in the py-version setting:HIGH |
18 changes: 9 additions & 9 deletions
18
tests/functional/u/unsupported/unsupported_version_for_final.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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
using-final-decorator-in-unsupported-version:10:1:10:6:MyClass1:typing.final is not supported by all versions included in the py-version setting:UNDEFINED | ||
using-final-decorator-in-unsupported-version:12:5:12:10:MyClass1.my_method:typing.final is not supported by all versions included in the py-version setting:UNDEFINED | ||
using-final-decorator-in-unsupported-version:13:5:13:10:MyClass1.my_method:typing.final is not supported by all versions included in the py-version setting:UNDEFINED | ||
using-final-decorator-in-unsupported-version:18:1:18:8:MyClass2:typing.final is not supported by all versions included in the py-version setting:UNDEFINED | ||
using-final-decorator-in-unsupported-version:20:5:20:12:MyClass2.my_method:typing.final is not supported by all versions included in the py-version setting:UNDEFINED | ||
using-final-decorator-in-unsupported-version:25:1:25:13:MyClass3:typing.final is not supported by all versions included in the py-version setting:UNDEFINED | ||
using-final-decorator-in-unsupported-version:27:5:27:17:MyClass3.my_method:typing.final is not supported by all versions included in the py-version setting:UNDEFINED | ||
using-final-decorator-in-unsupported-version:32:1:32:15:MyClass4:typing.final is not supported by all versions included in the py-version setting:UNDEFINED | ||
using-final-decorator-in-unsupported-version:34:5:34:19:MyClass4.my_method:typing.final is not supported by all versions included in the py-version setting:UNDEFINED | ||
using-final-decorator-in-unsupported-version:10:1:10:6:MyClass1:typing.final is not supported by all versions included in the py-version setting:HIGH | ||
using-final-decorator-in-unsupported-version:12:5:12:10:MyClass1.my_method:typing.final is not supported by all versions included in the py-version setting:HIGH | ||
using-final-decorator-in-unsupported-version:13:5:13:10:MyClass1.my_method:typing.final is not supported by all versions included in the py-version setting:HIGH | ||
using-final-decorator-in-unsupported-version:18:1:18:8:MyClass2:typing.final is not supported by all versions included in the py-version setting:HIGH | ||
using-final-decorator-in-unsupported-version:20:5:20:12:MyClass2.my_method:typing.final is not supported by all versions included in the py-version setting:HIGH | ||
using-final-decorator-in-unsupported-version:25:1:25:13:MyClass3:typing.final is not supported by all versions included in the py-version setting:HIGH | ||
using-final-decorator-in-unsupported-version:27:5:27:17:MyClass3.my_method:typing.final is not supported by all versions included in the py-version setting:HIGH | ||
using-final-decorator-in-unsupported-version:32:1:32:15:MyClass4:typing.final is not supported by all versions included in the py-version setting:HIGH | ||
using-final-decorator-in-unsupported-version:34:5:34:19:MyClass4.my_method:typing.final is not supported by all versions included in the py-version setting:HIGH |
8 changes: 4 additions & 4 deletions
8
tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
using-generic-type-syntax-in-unsupported-version:3:0:3:35::Generic type syntax (PEP 695) is not supported by all versions included in the py-version setting:UNDEFINED | ||
using-generic-type-syntax-in-unsupported-version:3:11:3:12::Generic type syntax (PEP 695) is not supported by all versions included in the py-version setting:UNDEFINED | ||
using-generic-type-syntax-in-unsupported-version:5:0:5:28::Generic type syntax (PEP 695) is not supported by all versions included in the py-version setting:UNDEFINED | ||
using-generic-type-syntax-in-unsupported-version:5:11:5:14::Generic type syntax (PEP 695) is not supported by all versions included in the py-version setting:UNDEFINED | ||
using-generic-type-syntax-in-unsupported-version:3:0:3:35::Generic type syntax (PEP 695) is not supported by all versions included in the py-version setting:HIGH | ||
using-generic-type-syntax-in-unsupported-version:3:11:3:12::Generic type syntax (PEP 695) is not supported by all versions included in the py-version setting:HIGH | ||
using-generic-type-syntax-in-unsupported-version:5:0:5:28::Generic type syntax (PEP 695) is not supported by all versions included in the py-version setting:HIGH | ||
using-generic-type-syntax-in-unsupported-version:5:11:5:14::Generic type syntax (PEP 695) is not supported by all versions included in the py-version setting:HIGH |
3 changes: 3 additions & 0 deletions
3
tests/functional/u/unsupported/unsupported_version_for_posonly_args.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,3 @@ | ||
# pylint: disable=missing-function-docstring, missing-module-docstring | ||
def add(x, y, /): # [using-positional-only-args-in-unsupported-version] | ||
return x + y |
2 changes: 2 additions & 0 deletions
2
tests/functional/u/unsupported/unsupported_version_for_posonly_args.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,2 @@ | ||
[main] | ||
py-version=3.7 |
1 change: 1 addition & 0 deletions
1
tests/functional/u/unsupported/unsupported_version_for_posonly_args.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 @@ | ||
using-positional-only-args-in-unsupported-version:2:0:None:None:add:Positional-only arguments are not supported by all versions included in the py-version setting:HIGH |