-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 major 3.11 and 3.12 features (#9792)
* Bump DEFAULT_PYTHON checks.yaml to 3.12
- Loading branch information
1 parent
47fb321
commit e2c15e3
Showing
22 changed files
with
155 additions
and
4 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
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 +1 @@ | ||
string = "\z" # [anomalous-backslash-in-string] | ||
string = "\z" # [syntax-error] |
4 changes: 4 additions & 0 deletions
4
doc/data/messages/a/anomalous-backslash-in-string/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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
``\z`` is same as ``\\z`` because there's no escape sequence for ``z``. But it is not clear | ||
for the reader of the code. | ||
|
||
The only reason this is demonstrated to raise ``syntax-error`` is because | ||
pylint's CI now runs on Python 3.12, where this truly raises a ``SyntaxError``. | ||
We hope to address this discrepancy in the documentation in the future. |
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 +1 @@ | ||
print(b"\u%b" % b"0394") # [anomalous-unicode-escape-in-string] | ||
print(b"\u%b" % b"0394") # [syntax-error] |
12 changes: 12 additions & 0 deletions
12
doc/data/messages/u/using-exception-groups-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,12 @@ | ||
def f(): | ||
excs = [OSError("error 1"), SystemError("error 2")] | ||
# +1: [using-exception-groups-in-unsupported-version] | ||
raise ExceptionGroup("there were problems", excs) | ||
|
||
|
||
try: # [using-exception-groups-in-unsupported-version] | ||
f() | ||
except* OSError as e: | ||
print("There were OSErrors") | ||
except* SystemError as e: | ||
print("There were SystemErrors") |
1 change: 1 addition & 0 deletions
1
doc/data/messages/u/using-exception-groups-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 @@ | ||
Exception groups were introduced in Python 3.11; to use it, please use a more recent version of Python. |
10 changes: 10 additions & 0 deletions
10
doc/data/messages/u/using-exception-groups-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,10 @@ | ||
def f(): | ||
raise OSError("error 1") | ||
|
||
|
||
try: | ||
f() | ||
except OSError as e: | ||
print("There were OSErrors") | ||
except SystemError as e: | ||
print("There were SystemErrors") |
2 changes: 2 additions & 0 deletions
2
doc/data/messages/u/using-exception-groups-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.10 |
1 change: 1 addition & 0 deletions
1
doc/data/messages/u/using-generic-type-syntax-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 @@ | ||
type Vector = list[float] # [using-generic-type-syntax-in-unsupported-version] |
1 change: 1 addition & 0 deletions
1
doc/data/messages/u/using-generic-type-syntax-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 @@ | ||
Generic type syntax was introduced in Python 3.12; to use it, please use a more recent version of Python. |
3 changes: 3 additions & 0 deletions
3
doc/data/messages/u/using-generic-type-syntax-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 @@ | ||
from typing import TypeAlias | ||
|
||
Vector: TypeAlias = list[float] |
2 changes: 2 additions & 0 deletions
2
doc/data/messages/u/using-generic-type-syntax-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.11 |
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,5 @@ | ||
Add `using-exception-group-in-unsupported-version` and | ||
`using-generic-type-syntax-in-unsupported-version` for uses of Python 3.11+ or | ||
3.12+ features on lower supported versions provided with `--py-version`. | ||
|
||
Closes #9791 |
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
21 changes: 21 additions & 0 deletions
21
tests/functional/u/unsupported/unsupported_version_for_exception_group.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,21 @@ | ||
# pylint: disable=missing-function-docstring, missing-module-docstring | ||
def f(): | ||
excs = [OSError("error 1"), SystemError("error 2")] | ||
# +1: [using-exception-groups-in-unsupported-version] | ||
raise ExceptionGroup("there were problems", excs) | ||
|
||
|
||
try: # [using-exception-groups-in-unsupported-version] | ||
f() | ||
except* OSError as e: | ||
print("There were OSErrors") | ||
except* SystemError as e: | ||
print("There were SystemErrors") | ||
|
||
|
||
try: | ||
f() | ||
except ExceptionGroup as group: # [using-exception-groups-in-unsupported-version] | ||
# https://github.com/pylint-dev/pylint/issues/8985 | ||
for exc in group.exceptions: # pylint: disable=not-an-iterable | ||
print("ERROR: ", exc) |
5 changes: 5 additions & 0 deletions
5
tests/functional/u/unsupported/unsupported_version_for_exception_group.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 @@ | ||
[main] | ||
py-version=3.10 | ||
|
||
[testoptions] | ||
min_pyver=3.11 |
3 changes: 3 additions & 0 deletions
3
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 |
---|---|---|
@@ -0,0 +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 |
5 changes: 5 additions & 0 deletions
5
tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.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-function-docstring, missing-module-docstring, line-too-long | ||
# +1: [using-generic-type-syntax-in-unsupported-version, using-generic-type-syntax-in-unsupported-version] | ||
type Point[T] = tuple[float, float] | ||
# +1: [using-generic-type-syntax-in-unsupported-version, using-generic-type-syntax-in-unsupported-version] | ||
type Alias[*Ts] = tuple[*Ts] |
5 changes: 5 additions & 0 deletions
5
tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.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 @@ | ||
[main] | ||
py-version=3.11 | ||
|
||
[testoptions] | ||
min_pyver=3.12 |
4 changes: 4 additions & 0 deletions
4
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 |
---|---|---|
@@ -0,0 +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 |