From 9f96db4e7f80c61e68f9bb56fb68b9d9a4ccab7a84f24c717b2b91f3b89027f5 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Sun, 30 Jun 2024 22:11:35 +0000 Subject: [PATCH 1/2] - update to 3.2.5: * Fixed a false positive ``unreachable-code`` when using ``typing.Any`` as return type in python 3.8, the ``typing.NoReturn`` are not taken into account anymore for python 3.8 however. * Prevent emitting ``possibly-used-before-assignment`` when relying on names only potentially not defined in conditional blocks guarded by functions annotated with ``typing.Never`` or ``typing.NoReturn``. - update to 3.2.3: * Classes with only an Ellipsis (``...``) in their body do not trigger 'multiple-statements' anymore if they are inlined * Fix a false positive for ``redefined-outer-name`` when there is a name defined in an exception-handling block which shares the same name as a local variable that has been defined in a function body. * Fix a false positive for ``use-yield-from`` when using the return value from the ``yield`` atom. - update to 3.2.2: * Fix multiple false positives for generic class syntax added in Python 3.12 (PEP 695). * Exclude context manager without cleanup from ``contextmanager-generator-missing-cleanup`` checks. - update to 3.2.1: * Exclude if/else branches containing terminating functions (e.g. `sys.exit()`) from `possibly-used-before-assignment` checks. * Don't emit ``typevar-name-incorrect-variance`` warnings for PEP 695 style TypeVars. * The variance is inferred automatically by the type checker. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pylint?expand=0&rev=158 --- pylint-3.1.0-gh.tar.gz | 3 --- pylint-3.2.5-gh.tar.gz | 3 +++ python-pylint.changes | 52 ++++++++++++++++++++++++++++++++++++++++++ python-pylint.spec | 6 ++--- 4 files changed, 58 insertions(+), 6 deletions(-) delete mode 100644 pylint-3.1.0-gh.tar.gz create mode 100644 pylint-3.2.5-gh.tar.gz diff --git a/pylint-3.1.0-gh.tar.gz b/pylint-3.1.0-gh.tar.gz deleted file mode 100644 index 2c880ef..0000000 --- a/pylint-3.1.0-gh.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c4c13c6b77f6604367763f906e5df4e9f4c7fbfa6e8553f31493adfabfc73092 -size 1433040 diff --git a/pylint-3.2.5-gh.tar.gz b/pylint-3.2.5-gh.tar.gz new file mode 100644 index 0000000..3758952 --- /dev/null +++ b/pylint-3.2.5-gh.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7860e1f334c338e8400567df893ebe0934c162737f9bc22eb6f0a9c530a52cfc +size 1446535 diff --git a/python-pylint.changes b/python-pylint.changes index 8922bb8..ef87b39 100644 --- a/python-pylint.changes +++ b/python-pylint.changes @@ -1,3 +1,55 @@ +------------------------------------------------------------------- +Sun Jun 30 22:05:58 UTC 2024 - Dirk Müller + +- update to 3.2.5: + * Fixed a false positive ``unreachable-code`` when using + ``typing.Any`` as return type in python 3.8, the + ``typing.NoReturn`` are not taken into account + anymore for python 3.8 however. + * Prevent emitting ``possibly-used-before-assignment`` when + relying on names only potentially not defined in conditional + blocks guarded by functions annotated with ``typing.Never`` + or ``typing.NoReturn``. +- update to 3.2.3: + * Classes with only an Ellipsis (``...``) in their body do not + trigger 'multiple-statements' anymore if they are inlined + * Fix a false positive for ``redefined-outer-name`` when there + is a name defined in an exception-handling block which shares + the same name as a local variable that has been defined in a + function body. + * Fix a false positive for ``use-yield-from`` when using the + return value from the ``yield`` atom. +- update to 3.2.2: + * Fix multiple false positives for generic class syntax added + in Python 3.12 (PEP 695). + * Exclude context manager without cleanup from + ``contextmanager-generator-missing-cleanup`` checks. +- update to 3.2.1: + * Exclude if/else branches containing terminating functions + (e.g. `sys.exit()`) from `possibly-used-before-assignment` + checks. + * Don't emit ``typevar-name-incorrect-variance`` warnings for + PEP 695 style TypeVars. + * The variance is inferred automatically by the type checker. + * Adding ``_co`` or ``_contra`` suffix can help to reason about + TypeVar. +- update to 3.2.0: + * Understand `six.PY2` and `six.PY3` for conditional imports. + * Github can use to automatically annotate code. Use it with + `pylint --output-format=github` on your Github Workflows. + * Add check ``possibly-used-before-assignment`` when relying on + names after an ``if/else`` switch when one branch failed to + define the name, raise, or return. + * Checks for generators that use contextmanagers that don't + handle cleanup properly. + * Is meant to raise visibilty on the case that a generator is + not fully exhausted and the contextmanager is not cleaned up + properly. + * A contextmanager must yield a non-constant value and not + handle cleanup for GeneratorExit. + * The using generator must attempt to use the yielded context + value `with x() as y` and not just `with x()`. + ------------------------------------------------------------------- Fri Mar 22 20:01:42 UTC 2024 - Dirk Müller diff --git a/python-pylint.spec b/python-pylint.spec index 3bfdcea..0a40ee7 100644 --- a/python-pylint.spec +++ b/python-pylint.spec @@ -19,7 +19,7 @@ %{?sle15_python_module_pythons} %bcond_without tests Name: python-pylint -Version: 3.1.0 +Version: 3.2.5 Release: 0 Summary: Syntax and style checker for Python code License: GPL-2.0-or-later @@ -36,7 +36,7 @@ BuildRequires: python-rpm-macros Requires: python-dill >= 0.3.6 Requires: python-platformdirs >= 2.2 Requires: python-tomlkit >= 0.10.1 -Requires: (python-astroid >= 3.1.0 with python-astroid < 3.2.0~dev0) +Requires: (python-astroid >= 3.2.2 with python-astroid < 3.3.0~dev0) Requires: (python-isort >= 4.2.5 with python-isort < 6) Requires: (python-mccabe >= 0.6 with python-mccabe < 0.8) %if 0%{?python_version_nodots} < 311 @@ -45,7 +45,7 @@ Requires: python-tomli >= 1.1.0 Requires: python-typing-extensions >= 4.9 %if %{with tests} # SECTION pylint deps -BuildRequires: %{python_module astroid >= 3.1.0 with %python-astroid < 3.2.0~dev0} +BuildRequires: %{python_module astroid >= 3.2.2 with %python-astroid < 3.3.0~dev0} BuildRequires: %{python_module dill >= 0.3.6} BuildRequires: %{python_module isort >= 4.2.5 with %python-isort < 6} BuildRequires: %{python_module mccabe >= 0.6 with %python-mccabe < 0.8} From 773708ceb90d65c5d61ea3e4cbc5535cd2ae8bc55fd3b82fd1a34e9ef27bcdcd Mon Sep 17 00:00:00 2001 From: Daniel Garcia Date: Tue, 9 Jul 2024 12:16:59 +0000 Subject: [PATCH 2/2] - Add new patch to fix failing tests with pytest 8, pytest-8.patch gh#pylint-dev/pylint#9576 - Skip some tests that still are failing with pytest 8, gh#pylint-dev/pylint#9545 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pylint?expand=0&rev=159 --- pytest-8.patch | 206 ++++++++++++++++++++++++++++++++++++++++++ python-pylint.changes | 8 ++ python-pylint.spec | 9 +- 3 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 pytest-8.patch diff --git a/pytest-8.patch b/pytest-8.patch new file mode 100644 index 0000000..bc8b9f6 --- /dev/null +++ b/pytest-8.patch @@ -0,0 +1,206 @@ +Index: pylint-3.2.5/pylint/testutils/configuration_test.py +=================================================================== +--- pylint-3.2.5.orig/pylint/testutils/configuration_test.py ++++ pylint-3.2.5/pylint/testutils/configuration_test.py +@@ -12,7 +12,6 @@ import logging + import unittest + from pathlib import Path + from typing import Any, Dict +-from unittest.mock import Mock + + from pylint.lint import Run + +@@ -135,18 +134,15 @@ def get_expected_output( + + def run_using_a_configuration_file( + configuration_path: Path | str, file_to_lint: str = __file__ +-) -> tuple[Mock, Mock, Run]: ++) -> Run: + """Simulate a run with a configuration without really launching the checks.""" + configuration_path = str(configuration_path) + args = ["--rcfile", configuration_path, file_to_lint] +- # We do not capture the `SystemExit` as then the `runner` variable +- # would not be accessible outside the `with` block. +- with unittest.mock.patch("sys.exit") as mocked_exit: +- # Do not actually run checks, that could be slow. We don't mock +- # `PyLinter.check`: it calls `PyLinter.initialize` which is +- # needed to properly set up messages inclusion/exclusion +- # in `_msg_states`, used by `is_message_enabled`. +- check = "pylint.lint.pylinter.check_parallel" +- with unittest.mock.patch(check) as mocked_check_parallel: +- runner = Run(args) +- return mocked_exit, mocked_check_parallel, runner ++ # Do not actually run checks, that could be slow. We don't mock ++ # `PyLinter.check`: it calls `PyLinter.initialize` which is ++ # needed to properly set up messages inclusion/exclusion ++ # in `_msg_states`, used by `is_message_enabled`. ++ check = "pylint.lint.pylinter.check_parallel" ++ with unittest.mock.patch(check): ++ runner = Run(args, exit=False) ++ return runner +Index: pylint-3.2.5/requirements_test_min.txt +=================================================================== +--- pylint-3.2.5.orig/requirements_test_min.txt ++++ pylint-3.2.5/requirements_test_min.txt +@@ -3,7 +3,7 @@ + astroid==3.2.2 # Pinned to a specific version for tests + typing-extensions~=4.11 + py~=1.11.0 +-pytest~=7.4 ++pytest~=8.2 + pytest-benchmark~=4.0 + pytest-timeout~=2.3 + towncrier~=23.11 +Index: pylint-3.2.5/tests/config/test_config.py +=================================================================== +--- pylint-3.2.5.orig/tests/config/test_config.py ++++ pylint-3.2.5/tests/config/test_config.py +@@ -55,10 +55,8 @@ reports = "yes" + ) + env_var = "tmp_path_env" + os.environ[env_var] = str(config_file) +- mock_exit, _, runner = run_using_a_configuration_file( +- f"${env_var}", file_to_lint_path +- ) +- mock_exit.assert_called_once_with(0) ++ runner = run_using_a_configuration_file(f"${env_var}", file_to_lint_path) ++ assert runner.linter.msg_status == 0 + check_configuration_file_reader(runner) + + +@@ -226,7 +224,7 @@ def test_disable_before_enable_all_takes + runner = Run(["--disable=fixme", "--enable=all", str(FIXME_MODULE)], exit=False) + assert not runner.linter.stats.by_msg + +- _, _, toml_runner = run_using_a_configuration_file( ++ toml_runner = run_using_a_configuration_file( + HERE + / "functional" + / "toml" +@@ -239,7 +237,7 @@ def test_enable_before_disable_all_takes + runner = Run(["--enable=fixme", "--disable=all", str(FIXME_MODULE)], exit=False) + assert runner.linter.stats.by_msg + +- _, _, toml_runner = run_using_a_configuration_file( ++ toml_runner = run_using_a_configuration_file( + HERE + / "functional" + / "toml" +Index: pylint-3.2.5/tests/config/test_functional_config_loading.py +=================================================================== +--- pylint-3.2.5.orig/tests/config/test_functional_config_loading.py ++++ pylint-3.2.5/tests/config/test_functional_config_loading.py +@@ -57,10 +57,8 @@ def default_configuration( + ) -> PylintConfiguration: + empty_pylintrc = tmp_path / "pylintrc" + empty_pylintrc.write_text("") +- mock_exit, _, runner = run_using_a_configuration_file( +- str(empty_pylintrc), file_to_lint_path +- ) +- mock_exit.assert_called_once_with(0) ++ runner = run_using_a_configuration_file(str(empty_pylintrc), file_to_lint_path) ++ assert runner.linter.msg_status == 0 + return runner.linter.config.__dict__ + + +@@ -88,10 +86,8 @@ def test_functional_config_loading( + warnings.filterwarnings( + "ignore", message="The use of 'MASTER'.*", category=UserWarning + ) +- mock_exit, _, runner = run_using_a_configuration_file( +- configuration_path, file_to_lint_path +- ) +- mock_exit.assert_called_once_with(expected_code) ++ runner = run_using_a_configuration_file(configuration_path, file_to_lint_path) ++ assert runner.linter.msg_status == expected_code + out, err = capsys.readouterr() + # 'rstrip()' applied, so we can have a final newline in the expected test file + assert expected_output.rstrip() == out.rstrip(), msg +Index: pylint-3.2.5/tests/lint/unittest_lint.py +=================================================================== +--- pylint-3.2.5.orig/tests/lint/unittest_lint.py ++++ pylint-3.2.5/tests/lint/unittest_lint.py +@@ -20,6 +20,7 @@ from pathlib import Path + from shutil import copy, rmtree + from unittest import mock + ++import astroid + import platformdirs + import pytest + from astroid import nodes +@@ -1053,7 +1054,9 @@ def test_finds_pyi_file() -> None: + exit=False, + ) + assert run.linter.current_file is not None +- assert run.linter.current_file.endswith("foo.pyi") ++ assert run.linter.current_file.endswith( ++ "a_module_that_we_definitely_dont_use_in_the_functional_tests.pyi" ++ ) + + + def test_recursive_finds_pyi_file() -> None: +@@ -1068,7 +1071,9 @@ def test_recursive_finds_pyi_file() -> N + exit=False, + ) + assert run.linter.current_file is not None +- assert run.linter.current_file.endswith("foo.pyi") ++ assert run.linter.current_file.endswith( ++ "a_module_that_we_definitely_dont_use_in_the_functional_tests.pyi" ++ ) + + + def test_no_false_positive_from_pyi_stub() -> None: +@@ -1126,6 +1131,9 @@ def test_recursive_ignore(ignore_paramet + ): + module = os.path.abspath(join(REGRTEST_DATA_DIR, *regrtest_data_module)) + assert module in linted_file_paths ++ # We lint the modules in `regrtest` in other tests as well. Prevent test pollution by ++ # explicitly clearing the astroid caches. ++ astroid.MANAGER.clear_cache() + + + def test_source_roots_globbing() -> None: +Index: pylint-3.2.5/tests/regrtest_data/pyi/a_module_that_we_definitely_dont_use_in_the_functional_tests.pyi +=================================================================== +--- /dev/null ++++ pylint-3.2.5/tests/regrtest_data/pyi/a_module_that_we_definitely_dont_use_in_the_functional_tests.pyi +@@ -0,0 +1,5 @@ ++# This module is named in a particular way to prevent test pollution. It was previously named 'foo' and ++# all mentions of 'foo' were wrongly resolved to this stub file. ++foo = 1 ++ ++def three_item_iterable(): ... +Index: pylint-3.2.5/tests/regrtest_data/pyi/foo.pyi +=================================================================== +--- pylint-3.2.5.orig/tests/regrtest_data/pyi/foo.pyi ++++ /dev/null +@@ -1,4 +0,0 @@ +-foo = 1 +- +-def three_item_iterable(): +- ... +Index: pylint-3.2.5/tests/regrtest_data/uses_module_with_stub.py +=================================================================== +--- pylint-3.2.5.orig/tests/regrtest_data/uses_module_with_stub.py ++++ pylint-3.2.5/tests/regrtest_data/uses_module_with_stub.py +@@ -1,5 +1,5 @@ + """If the stub is preferred over the .py, this might emit not-an-iterable""" +-from pyi.foo import three_item_iterable ++from pyi.a_module_that_we_definitely_dont_use_in_the_functional_tests import three_item_iterable + + for val in three_item_iterable(): + print(val) +Index: pylint-3.2.5/tests/regrtest_data/pyi/a_module_that_we_definitely_dont_use_in_the_functional_tests.py +=================================================================== +--- /dev/null ++++ pylint-3.2.5/tests/regrtest_data/pyi/a_module_that_we_definitely_dont_use_in_the_functional_tests.py +@@ -0,0 +1,2 @@ ++def three_item_iterable(): ++ return [1, 2, 3] +Index: pylint-3.2.5/tests/regrtest_data/pyi/foo.py +=================================================================== +--- pylint-3.2.5.orig/tests/regrtest_data/pyi/foo.py ++++ /dev/null +@@ -1,2 +0,0 @@ +-def three_item_iterable(): +- return [1, 2, 3] diff --git a/python-pylint.changes b/python-pylint.changes index ef87b39..f1de185 100644 --- a/python-pylint.changes +++ b/python-pylint.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Tue Jul 9 11:59:18 UTC 2024 - Daniel Garcia + +- Add new patch to fix failing tests with pytest 8, pytest-8.patch + gh#pylint-dev/pylint#9576 +- Skip some tests that still are failing with pytest 8, + gh#pylint-dev/pylint#9545 + ------------------------------------------------------------------- Sun Jun 30 22:05:58 UTC 2024 - Dirk Müller diff --git a/python-pylint.spec b/python-pylint.spec index 0a40ee7..dafd0c3 100644 --- a/python-pylint.spec +++ b/python-pylint.spec @@ -27,6 +27,8 @@ Group: Development/Languages/Python URL: https://github.com/pycqa/pylint # Tests are no longer packaged in the PyPI sdist, use GitHub archive Source: https://github.com/PyCQA/pylint/archive/refs/tags/v%{version}.tar.gz#/pylint-%{version}-gh.tar.gz +# PATCH-FIX-UPSTREAM pytest-8.patch gh#pylint-dev/pylint#9576 +Patch1: pytest-8.patch BuildRequires: %{python_module base >= 3.7.2} BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} @@ -104,7 +106,12 @@ done %check export LC_ALL="en_US.UTF-8" # reruns: tests/pyreverse is incredibly non-deterministic in failures -%pytest -n auto --ignore tests/benchmark --reruns 5 -rsfER -k "not test_linter_with_unpickleable_plugins_is_pickleable" +donttest="test_linter_with_unpickleable_plugins_is_pickleable" +# Fails with pytest-8 gh#pylint-dev/pylint#9545 +donttest+=" or recursion_error_3159" +# Fails with python 3.12 +donttest+=" or test_functional_relation_extraction" +%pytest -n auto --ignore tests/benchmark --reruns 5 -rsfER -k "not ($donttest)" %endif %post