From 1de5745e17f547155282ea1189f0e190ed4f11cf Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sun, 14 Jul 2024 14:04:36 -0400 Subject: [PATCH 01/12] Add unsupported version checks for major 3.11 and 3.12 features --- .../bad.py | 11 ++++ .../details.rst | 1 + .../good.py | 10 ++++ .../pylintrc | 2 + .../bad.py | 1 + .../details.rst | 1 + .../good.py | 3 + .../pylintrc | 2 + doc/whatsnew/fragments/9791.new_check | 5 ++ pylint/checkers/unsupported_version.py | 59 +++++++++++++++++++ 10 files changed, 95 insertions(+) create mode 100644 doc/data/messages/u/using-exception-groups-in-unsupported-version/bad.py create mode 100644 doc/data/messages/u/using-exception-groups-in-unsupported-version/details.rst create mode 100644 doc/data/messages/u/using-exception-groups-in-unsupported-version/good.py create mode 100644 doc/data/messages/u/using-exception-groups-in-unsupported-version/pylintrc create mode 100644 doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/bad.py create mode 100644 doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/details.rst create mode 100644 doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/good.py create mode 100644 doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/pylintrc create mode 100644 doc/whatsnew/fragments/9791.new_check diff --git a/doc/data/messages/u/using-exception-groups-in-unsupported-version/bad.py b/doc/data/messages/u/using-exception-groups-in-unsupported-version/bad.py new file mode 100644 index 0000000000..a9daa0bdf6 --- /dev/null +++ b/doc/data/messages/u/using-exception-groups-in-unsupported-version/bad.py @@ -0,0 +1,11 @@ +def f(): + excs = [OSError("error 1"), SystemError("error 2")] + raise ExceptionGroup("there were problems", excs) + + +try: + f() +except* OSError as e: + print("There were OSErrors") +except* SystemError as e: + print("There were SystemErrors") diff --git a/doc/data/messages/u/using-exception-groups-in-unsupported-version/details.rst b/doc/data/messages/u/using-exception-groups-in-unsupported-version/details.rst new file mode 100644 index 0000000000..8d05a037a1 --- /dev/null +++ b/doc/data/messages/u/using-exception-groups-in-unsupported-version/details.rst @@ -0,0 +1 @@ +Exception groups were introduced in Python 3.11; to use it, please use a more recent version of Python. diff --git a/doc/data/messages/u/using-exception-groups-in-unsupported-version/good.py b/doc/data/messages/u/using-exception-groups-in-unsupported-version/good.py new file mode 100644 index 0000000000..e7ac7a5b7a --- /dev/null +++ b/doc/data/messages/u/using-exception-groups-in-unsupported-version/good.py @@ -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") diff --git a/doc/data/messages/u/using-exception-groups-in-unsupported-version/pylintrc b/doc/data/messages/u/using-exception-groups-in-unsupported-version/pylintrc new file mode 100644 index 0000000000..d36622d880 --- /dev/null +++ b/doc/data/messages/u/using-exception-groups-in-unsupported-version/pylintrc @@ -0,0 +1,2 @@ +[main] +py-version=3.10 diff --git a/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/bad.py b/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/bad.py new file mode 100644 index 0000000000..d43e84a393 --- /dev/null +++ b/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/bad.py @@ -0,0 +1 @@ +type VectorT = list[float] diff --git a/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/details.rst b/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/details.rst new file mode 100644 index 0000000000..731616e853 --- /dev/null +++ b/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/details.rst @@ -0,0 +1 @@ +Generic type syntax was introduced in Python 3.12; to use it, please use a more recent version of Python. diff --git a/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/good.py b/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/good.py new file mode 100644 index 0000000000..463498eac9 --- /dev/null +++ b/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/good.py @@ -0,0 +1,3 @@ +from typing import TypeAlias + +VectorT: TypeAlias = list[float] diff --git a/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/pylintrc b/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/pylintrc new file mode 100644 index 0000000000..8e00cbfea2 --- /dev/null +++ b/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/pylintrc @@ -0,0 +1,2 @@ +[main] +py-version=3.11 diff --git a/doc/whatsnew/fragments/9791.new_check b/doc/whatsnew/fragments/9791.new_check new file mode 100644 index 0000000000..279c364420 --- /dev/null +++ b/doc/whatsnew/fragments/9791.new_check @@ -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 diff --git a/pylint/checkers/unsupported_version.py b/pylint/checkers/unsupported_version.py index 64f2630d8b..9e4d6ce8d6 100644 --- a/pylint/checkers/unsupported_version.py +++ b/pylint/checkers/unsupported_version.py @@ -42,6 +42,18 @@ class UnsupportedVersionChecker(BaseChecker): "Used when the py-version set by the user is lower than 3.8 and pylint encounters " "a ``typing.final`` decorator.", ), + "W2603": ( + "Exception groups are not supported by all versions included in the py-version setting", + "using-exception-groups-in-unsupported-version", + "Used when the py-version set by the user is lower than 3.11 and pylint encounters " + "``except*`` or ``except ExceptionGroup``.", + ), + "W2604": ( + "Generic type syntax (PEP 695) is not supported by all versions included in the py-version setting", + "using-generic-type-syntax-in-unsupported-version", + "Used when the py-version set by the user is lower than 3.11 and pylint encounters " + "``except*`` or ``except ExceptionGroup``.", + ), } def open(self) -> None: @@ -49,6 +61,8 @@ def open(self) -> None: py_version = self.linter.config.py_version self._py36_plus = py_version >= (3, 6) self._py38_plus = py_version >= (3, 8) + self._py311_plus = py_version >= (3, 11) + self._py312_plus = py_version >= (3, 12) @only_required_for_messages("using-f-string-in-unsupported-version") def visit_joinedstr(self, node: nodes.JoinedStr) -> None: @@ -79,6 +93,51 @@ def _check_typing_final(self, node: nodes.Decorators) -> None: "using-final-decorator-in-unsupported-version", node=decorator ) + @only_required_for_messages("using-exception-groups-in-unsupported-version") + def visit_trystar(self, node: nodes.TryStar) -> None: + if not self._py311_plus: + self.add_message("using-exception-groups-in-unsupported-version", node=node) + + @only_required_for_messages("using-exception-groups-in-unsupported-version") + def visit_excepthandler(self, node: nodes.ExceptHandler) -> None: + if ( + not self._py311_plus + and isinstance(node.type, nodes.Name) + and node.type.name == "ExceptionGroup" + ): + self.add_message("using-exception-groups-in-unsupported-version", node=node) + + @only_required_for_messages("using-exception-groups-in-unsupported-version") + def visit_raise(self, node: nodes.Raise) -> None: + if ( + not self._py311_plus + and isinstance(node.exc, nodes.Call) + and isinstance(node.exc.func, nodes.Name) + and node.exc.func.name == "ExceptionGroup" + ): + self.add_message("using-exception-groups-in-unsupported-version", node=node) + + @only_required_for_messages("using-generic-type-syntax-in-unsupported-version") + def visit_typealias(self, node: nodes.TypeAlias) -> None: + if not self._py312_plus: + self.add_message( + "using-generic-type-syntax-in-unsupported-version", node=node + ) + + @only_required_for_messages("using-generic-type-syntax-in-unsupported-version") + def visit_typevar(self, node: nodes.TypeVar) -> None: + if not self._py312_plus: + self.add_message( + "using-generic-type-syntax-in-unsupported-version", node=node + ) + + @only_required_for_messages("using-generic-type-syntax-in-unsupported-version") + def visit_typevartuple(self, node: nodes.TypeVarTuple) -> None: + if not self._py312_plus: + self.add_message( + "using-generic-type-syntax-in-unsupported-version", node=node + ) + def register(linter: PyLinter) -> None: linter.register_checker(UnsupportedVersionChecker(linter)) From e6128819e60444a69d7fc0f0d0c93d698c51b5e4 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sun, 14 Jul 2024 14:16:01 -0400 Subject: [PATCH 02/12] fixup: add expected msgs --- .../u/using-exception-groups-in-unsupported-version/bad.py | 3 ++- .../u/using-generic-type-syntax-in-unsupported-version/bad.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/data/messages/u/using-exception-groups-in-unsupported-version/bad.py b/doc/data/messages/u/using-exception-groups-in-unsupported-version/bad.py index a9daa0bdf6..c225e6e6a8 100644 --- a/doc/data/messages/u/using-exception-groups-in-unsupported-version/bad.py +++ b/doc/data/messages/u/using-exception-groups-in-unsupported-version/bad.py @@ -1,9 +1,10 @@ def f(): excs = [OSError("error 1"), SystemError("error 2")] + # +1: [using-exception-groups-in-unsupported-version] raise ExceptionGroup("there were problems", excs) -try: +try: # [using-exception-groups-in-unsupported-version] f() except* OSError as e: print("There were OSErrors") diff --git a/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/bad.py b/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/bad.py index d43e84a393..a0a18542ee 100644 --- a/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/bad.py +++ b/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/bad.py @@ -1 +1 @@ -type VectorT = list[float] +type VectorT = list[float] # [using-generic-type-syntax-in-unsupported-version] From 29866c332d53fd8e610aecead2e3302a8d7a0a95 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sun, 14 Jul 2024 14:18:01 -0400 Subject: [PATCH 03/12] fixup: message descriptions --- pylint/checkers/unsupported_version.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylint/checkers/unsupported_version.py b/pylint/checkers/unsupported_version.py index 9e4d6ce8d6..e169b5f344 100644 --- a/pylint/checkers/unsupported_version.py +++ b/pylint/checkers/unsupported_version.py @@ -46,13 +46,13 @@ class UnsupportedVersionChecker(BaseChecker): "Exception groups are not supported by all versions included in the py-version setting", "using-exception-groups-in-unsupported-version", "Used when the py-version set by the user is lower than 3.11 and pylint encounters " - "``except*`` or ``except ExceptionGroup``.", + "``except*`` or `ExceptionGroup``.", ), "W2604": ( "Generic type syntax (PEP 695) is not supported by all versions included in the py-version setting", "using-generic-type-syntax-in-unsupported-version", "Used when the py-version set by the user is lower than 3.11 and pylint encounters " - "``except*`` or ``except ExceptionGroup``.", + "generic type syntax.", ), } From fd24e3182521fdac752b954c19ee6f6ebee7d0c1 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sun, 14 Jul 2024 14:19:07 -0400 Subject: [PATCH 04/12] fixup: msg description --- pylint/checkers/unsupported_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylint/checkers/unsupported_version.py b/pylint/checkers/unsupported_version.py index e169b5f344..23c6525302 100644 --- a/pylint/checkers/unsupported_version.py +++ b/pylint/checkers/unsupported_version.py @@ -51,7 +51,7 @@ class UnsupportedVersionChecker(BaseChecker): "W2604": ( "Generic type syntax (PEP 695) is not supported by all versions included in the py-version setting", "using-generic-type-syntax-in-unsupported-version", - "Used when the py-version set by the user is lower than 3.11 and pylint encounters " + "Used when the py-version set by the user is lower than 3.12 and pylint encounters " "generic type syntax.", ), } From e55964c386948c03f2fc2f9b232d32f1899def76 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sun, 14 Jul 2024 14:24:00 -0400 Subject: [PATCH 05/12] Bump DEFAULT_PYTHON checks.yaml to 3.12 --- .github/workflows/checks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index d3c9e01bbb..2d2bcd8115 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -13,7 +13,7 @@ on: env: CACHE_VERSION: 1 KEY_PREFIX: base-venv - DEFAULT_PYTHON: "3.11" + DEFAULT_PYTHON: "3.12" PRE_COMMIT_CACHE: ~/.cache/pre-commit concurrency: From a8634a7255a045d5de074b101784e144e1d9674a Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sun, 14 Jul 2024 14:31:03 -0400 Subject: [PATCH 06/12] Bump CACHE_VERSION in checks.yaml --- .github/workflows/checks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 2d2bcd8115..3d27ff0c1c 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -11,7 +11,7 @@ on: - "maintenance/**" env: - CACHE_VERSION: 1 + CACHE_VERSION: 2 KEY_PREFIX: base-venv DEFAULT_PYTHON: "3.12" PRE_COMMIT_CACHE: ~/.cache/pre-commit From 6e135fadb2cf161b9313b14c7874b0dd80607320 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sun, 14 Jul 2024 17:55:42 -0400 Subject: [PATCH 07/12] Expect syntax-error --- doc/data/messages/a/anomalous-backslash-in-string/bad.py | 2 +- doc/data/messages/a/anomalous-unicode-escape-in-string/bad.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/data/messages/a/anomalous-backslash-in-string/bad.py b/doc/data/messages/a/anomalous-backslash-in-string/bad.py index 08d8d1d6f4..32da7ddcc0 100644 --- a/doc/data/messages/a/anomalous-backslash-in-string/bad.py +++ b/doc/data/messages/a/anomalous-backslash-in-string/bad.py @@ -1 +1 @@ -string = "\z" # [anomalous-backslash-in-string] +string = "\z" # [syntax-error] diff --git a/doc/data/messages/a/anomalous-unicode-escape-in-string/bad.py b/doc/data/messages/a/anomalous-unicode-escape-in-string/bad.py index 40275f0551..21d25eadf0 100644 --- a/doc/data/messages/a/anomalous-unicode-escape-in-string/bad.py +++ b/doc/data/messages/a/anomalous-unicode-escape-in-string/bad.py @@ -1 +1 @@ -print(b"\u%b" % b"0394") # [anomalous-unicode-escape-in-string] +print(b"\u%b" % b"0394") # [syntax-error] From c6fbc335c5bb01ac09df07642b8a2586dbe053ca Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sun, 14 Jul 2024 18:22:04 -0400 Subject: [PATCH 08/12] Update msg overview --- doc/user_guide/messages/messages_overview.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/user_guide/messages/messages_overview.rst b/doc/user_guide/messages/messages_overview.rst index 4913ccd29f..0ead1ba37d 100644 --- a/doc/user_guide/messages/messages_overview.rst +++ b/doc/user_guide/messages/messages_overview.rst @@ -349,8 +349,10 @@ All messages in the warning category: warning/useless-type-doc warning/useless-with-lock warning/using-constant-test + warning/using-exception-groups-in-unsupported-version warning/using-f-string-in-unsupported-version warning/using-final-decorator-in-unsupported-version + warning/using-generic-type-syntax-in-unsupported-version warning/while-used warning/wildcard-import warning/wrong-exception-operation From 30f17ae27ed0db289554bcd43756bf41a1492449 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sun, 14 Jul 2024 20:56:25 -0400 Subject: [PATCH 09/12] Build docs --- doc/user_guide/checkers/features.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/user_guide/checkers/features.rst b/doc/user_guide/checkers/features.rst index 4dd5494b36..e0be9a44c5 100644 --- a/doc/user_guide/checkers/features.rst +++ b/doc/user_guide/checkers/features.rst @@ -1351,9 +1351,15 @@ Verbatim name of the checker is ``unsupported_version``. Unsupported Version checker Messages ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +:using-exception-groups-in-unsupported-version (W2603): *Exception groups are not supported by all versions included in the py-version setting* + Used when the py-version set by the user is lower than 3.11 and pylint + encounters ``except*`` or `ExceptionGroup``. :using-f-string-in-unsupported-version (W2601): *F-strings are not supported by all versions included in the py-version setting* Used when the py-version set by the user is lower than 3.6 and pylint encounters an f-string. +:using-generic-type-syntax-in-unsupported-version (W2604): *Generic type syntax (PEP 695) is not supported by all versions included in the py-version setting* + Used when the py-version set by the user is lower than 3.12 and pylint + encounters generic type syntax. :using-final-decorator-in-unsupported-version (W2602): *typing.final is not supported by all versions included in the py-version setting* Used when the py-version set by the user is lower than 3.8 and pylint encounters a ``typing.final`` decorator. From 373b418179a44fccb9829417fa2746ac1d6960cf Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Mon, 15 Jul 2024 19:03:09 -0400 Subject: [PATCH 10/12] Add functional tests --- .../bad.py | 2 +- .../good.py | 2 +- .../unsupported_version_for_exception_group.py | 13 +++++++++++++ .../unsupported_version_for_exception_group.rc | 5 +++++ .../unsupported_version_for_exception_group.txt | 2 ++ .../unsupported_version_for_generic_type_syntax.py | 4 ++++ .../unsupported_version_for_generic_type_syntax.rc | 5 +++++ .../unsupported_version_for_generic_type_syntax.txt | 3 +++ 8 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 tests/functional/u/unsupported/unsupported_version_for_exception_group.py create mode 100644 tests/functional/u/unsupported/unsupported_version_for_exception_group.rc create mode 100644 tests/functional/u/unsupported/unsupported_version_for_exception_group.txt create mode 100644 tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.py create mode 100644 tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.rc create mode 100644 tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.txt diff --git a/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/bad.py b/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/bad.py index a0a18542ee..b47bddd33e 100644 --- a/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/bad.py +++ b/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/bad.py @@ -1 +1 @@ -type VectorT = list[float] # [using-generic-type-syntax-in-unsupported-version] +type Vector = list[float] # [using-generic-type-syntax-in-unsupported-version] diff --git a/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/good.py b/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/good.py index 463498eac9..3f80b01c52 100644 --- a/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/good.py +++ b/doc/data/messages/u/using-generic-type-syntax-in-unsupported-version/good.py @@ -1,3 +1,3 @@ from typing import TypeAlias -VectorT: TypeAlias = list[float] +Vector: TypeAlias = list[float] diff --git a/tests/functional/u/unsupported/unsupported_version_for_exception_group.py b/tests/functional/u/unsupported/unsupported_version_for_exception_group.py new file mode 100644 index 0000000000..e9a3aef451 --- /dev/null +++ b/tests/functional/u/unsupported/unsupported_version_for_exception_group.py @@ -0,0 +1,13 @@ +# 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") diff --git a/tests/functional/u/unsupported/unsupported_version_for_exception_group.rc b/tests/functional/u/unsupported/unsupported_version_for_exception_group.rc new file mode 100644 index 0000000000..4885accdeb --- /dev/null +++ b/tests/functional/u/unsupported/unsupported_version_for_exception_group.rc @@ -0,0 +1,5 @@ +[main] +py-version=3.10 + +[testoptions] +min_pyver=3.11 diff --git a/tests/functional/u/unsupported/unsupported_version_for_exception_group.txt b/tests/functional/u/unsupported/unsupported_version_for_exception_group.txt new file mode 100644 index 0000000000..f701f55adb --- /dev/null +++ b/tests/functional/u/unsupported/unsupported_version_for_exception_group.txt @@ -0,0 +1,2 @@ +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 diff --git a/tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.py b/tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.py new file mode 100644 index 0000000000..d47b8a41dd --- /dev/null +++ b/tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.py @@ -0,0 +1,4 @@ +# pylint: disable=missing-function-docstring, missing-module-docstring, line-too-long +type Vector = list[float] # [using-generic-type-syntax-in-unsupported-version] +# +1: [using-generic-type-syntax-in-unsupported-version, using-generic-type-syntax-in-unsupported-version] +type Alias[*Ts] = tuple[*Ts] diff --git a/tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.rc b/tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.rc new file mode 100644 index 0000000000..884bba53e2 --- /dev/null +++ b/tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.rc @@ -0,0 +1,5 @@ +[main] +py-version=3.11 + +[testoptions] +min_pyver=3.12 diff --git a/tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.txt b/tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.txt new file mode 100644 index 0000000000..c544012664 --- /dev/null +++ b/tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.txt @@ -0,0 +1,3 @@ +using-generic-type-syntax-in-unsupported-version:2:0:2:25::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:4:0:4: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:4:11:4:14::Generic type syntax (PEP 695) is not supported by all versions included in the py-version setting:UNDEFINED From b26041b11daccc47a43fb43a184136effd164b09 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Mon, 15 Jul 2024 19:07:21 -0400 Subject: [PATCH 11/12] Update details.rst --- doc/data/messages/a/anomalous-backslash-in-string/details.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/data/messages/a/anomalous-backslash-in-string/details.rst b/doc/data/messages/a/anomalous-backslash-in-string/details.rst index e716bc2d9c..7f73b513e9 100644 --- a/doc/data/messages/a/anomalous-backslash-in-string/details.rst +++ b/doc/data/messages/a/anomalous-backslash-in-string/details.rst @@ -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. From 390c3b473330c2d1951fecd3e18fdeb0f17be2d6 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Tue, 16 Jul 2024 07:45:12 -0400 Subject: [PATCH 12/12] Add coverage --- .../unsupported_version_for_exception_group.py | 8 ++++++++ .../unsupported_version_for_exception_group.txt | 1 + .../unsupported_version_for_generic_type_syntax.py | 3 ++- .../unsupported_version_for_generic_type_syntax.txt | 7 ++++--- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/functional/u/unsupported/unsupported_version_for_exception_group.py b/tests/functional/u/unsupported/unsupported_version_for_exception_group.py index e9a3aef451..6327e82f1d 100644 --- a/tests/functional/u/unsupported/unsupported_version_for_exception_group.py +++ b/tests/functional/u/unsupported/unsupported_version_for_exception_group.py @@ -11,3 +11,11 @@ def f(): 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) diff --git a/tests/functional/u/unsupported/unsupported_version_for_exception_group.txt b/tests/functional/u/unsupported/unsupported_version_for_exception_group.txt index f701f55adb..0736e67653 100644 --- a/tests/functional/u/unsupported/unsupported_version_for_exception_group.txt +++ b/tests/functional/u/unsupported/unsupported_version_for_exception_group.txt @@ -1,2 +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 diff --git a/tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.py b/tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.py index d47b8a41dd..66d56bd4c7 100644 --- a/tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.py +++ b/tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.py @@ -1,4 +1,5 @@ # pylint: disable=missing-function-docstring, missing-module-docstring, line-too-long -type Vector = list[float] # [using-generic-type-syntax-in-unsupported-version] +# +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] diff --git a/tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.txt b/tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.txt index c544012664..9b2eb6af43 100644 --- a/tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.txt +++ b/tests/functional/u/unsupported/unsupported_version_for_generic_type_syntax.txt @@ -1,3 +1,4 @@ -using-generic-type-syntax-in-unsupported-version:2:0:2:25::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:4:0:4: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:4:11:4: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: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