diff --git a/backport-Fix-a-crash-for-undefined-lineno-in-annotations.patch b/backport-Fix-a-crash-for-undefined-lineno-in-annotations.patch deleted file mode 100644 index f22a705675404393eb15adf4a3b5a9d8ad75c14c..0000000000000000000000000000000000000000 --- a/backport-Fix-a-crash-for-undefined-lineno-in-annotations.patch +++ /dev/null @@ -1,74 +0,0 @@ -From 6b66ca65b2c8e4562d5550694ba68bb6bb445034 Mon Sep 17 00:00:00 2001 -From: "github-actions[bot]" - <41898282+github-actions[bot]@users.noreply.github.com> -Date: Thu, 6 Jun 2024 23:30:27 +0200 -Subject: [PATCH] [undefined-variable] Fix a crash for undefined lineno in - annotations (#9705) (#9706) - -(cherry picked from commit f082174bc7f111e4e411b74a00e1cf9aa231ce39) - -Co-authored-by: Pierre Sassoulas ---- - doc/whatsnew/fragments/8866.bugfix | 3 +++ - pylint/checkers/variables.py | 15 ++++++++------- - .../functional/u/undefined/undefined_variable.py | 4 ++++ - .../functional/u/undefined/undefined_variable.txt | 1 + - 4 files changed, 16 insertions(+), 7 deletions(-) - create mode 100644 doc/whatsnew/fragments/8866.bugfix - -diff --git a/doc/whatsnew/fragments/8866.bugfix b/doc/whatsnew/fragments/8866.bugfix -new file mode 100644 -index 0000000000..2eba31dccb ---- /dev/null -+++ b/doc/whatsnew/fragments/8866.bugfix -@@ -0,0 +1,3 @@ -+Fixed a crash when the lineno of a variable used as an annotation wasn't available for ``undefined-variable``. -+ -+Closes #8866 -diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py -index 8447320b89..8e8b0e0bfb 100644 ---- a/pylint/checkers/variables.py -+++ b/pylint/checkers/variables.py -@@ -2295,13 +2295,14 @@ def _is_variable_violation( - # using a name defined earlier in the class containing the function. - if node is frame.returns and defframe.parent_of(frame.returns): - annotation_return = True -- if ( -- frame.returns.name in defframe.locals -- and defframe.locals[node.name][0].lineno < frame.lineno -- ): -- # Detect class assignments with a name defined earlier in the -- # class. In this case, no warning should be raised. -- maybe_before_assign = False -+ if frame.returns.name in defframe.locals: -+ definition = defframe.locals[node.name][0] -+ if definition.lineno is None or definition.lineno < frame.lineno: -+ # Detect class assignments with a name defined earlier in the -+ # class. In this case, no warning should be raised. -+ maybe_before_assign = False -+ else: -+ maybe_before_assign = True - else: - maybe_before_assign = True - if isinstance(node.parent, nodes.Arguments): -diff --git a/tests/functional/u/undefined/undefined_variable.py b/tests/functional/u/undefined/undefined_variable.py -index 194de114d3..19c134e77b 100644 ---- a/tests/functional/u/undefined/undefined_variable.py -+++ b/tests/functional/u/undefined/undefined_variable.py -@@ -380,3 +380,7 @@ def y(self) -> RepeatedReturnAnnotations: # [undefined-variable] - pass - def z(self) -> RepeatedReturnAnnotations: # [undefined-variable] - pass -+ -+class A: -+ def say_hello(self) -> __module__: # [undefined-variable] -+ ... -diff --git a/tests/functional/u/undefined/undefined_variable.txt b/tests/functional/u/undefined/undefined_variable.txt -index ea707c910a..c527c76d96 100644 ---- a/tests/functional/u/undefined/undefined_variable.txt -+++ b/tests/functional/u/undefined/undefined_variable.txt -@@ -37,3 +37,4 @@ undefined-variable:365:10:365:20:global_var_mixed_assignment:Undefined variable - undefined-variable:377:19:377:44:RepeatedReturnAnnotations.x:Undefined variable 'RepeatedReturnAnnotations':UNDEFINED - undefined-variable:379:19:379:44:RepeatedReturnAnnotations.y:Undefined variable 'RepeatedReturnAnnotations':UNDEFINED - undefined-variable:381:19:381:44:RepeatedReturnAnnotations.z:Undefined variable 'RepeatedReturnAnnotations':UNDEFINED -+undefined-variable:385:27:385:37:A.say_hello:Undefined variable '__module__':UNDEFINED diff --git a/backport-Fix-crashes-for-uninferrable-start-value-in-enumerate.patch b/backport-Fix-crashes-for-uninferrable-start-value-in-enumerate.patch deleted file mode 100644 index 435d922fe693bbe32a2a9f762f7087f327aa82f4..0000000000000000000000000000000000000000 --- a/backport-Fix-crashes-for-uninferrable-start-value-in-enumerate.patch +++ /dev/null @@ -1,67 +0,0 @@ -From c3e257925e313a19f42dd17d20179152f5f5db2f Mon Sep 17 00:00:00 2001 -From: "github-actions[bot]" - <41898282+github-actions[bot]@users.noreply.github.com> -Date: Thu, 6 Jun 2024 22:03:21 +0000 -Subject: [PATCH] [unnecessary-list-index-lookup] Fix crashes for uninferrable - 'start' value in 'enumerate' (#9704) (#9707) -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - ---------- - -Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> -(cherry picked from commit 9f8dcbd6a9d37d56a14b747b83d97d6b8527a2ab) - -Co-authored-by: Pierre Sassoulas ---- - doc/whatsnew/fragments/9078.bugfix | 4 ++++ - pylint/checkers/refactoring/refactoring_checker.py | 4 +++- - .../u/unnecessary/unnecessary_list_index_lookup.py | 11 +++++++++++ - 3 files changed, 18 insertions(+), 1 deletion(-) - create mode 100644 doc/whatsnew/fragments/9078.bugfix - -diff --git a/doc/whatsnew/fragments/9078.bugfix b/doc/whatsnew/fragments/9078.bugfix -new file mode 100644 -index 0000000000..2e48abc887 ---- /dev/null -+++ b/doc/whatsnew/fragments/9078.bugfix -@@ -0,0 +1,4 @@ -+Fixed a crash when the ``start`` value in an ``enumerate`` was non-constant and impossible to infer -+(like in``enumerate(apples, start=int(random_apple_index)``) for ``unnecessary-list-index-lookup``. -+ -+Closes #9078 -diff --git a/pylint/checkers/refactoring/refactoring_checker.py b/pylint/checkers/refactoring/refactoring_checker.py -index 9ffcecce12..a8bce74854 100644 ---- a/pylint/checkers/refactoring/refactoring_checker.py -+++ b/pylint/checkers/refactoring/refactoring_checker.py -@@ -2454,7 +2454,9 @@ def _get_start_value(self, node: nodes.NodeNG) -> tuple[int | None, Confidence]: - and isinstance(node.operand, (nodes.Attribute, nodes.Name)) - ): - inferred = utils.safe_infer(node) -- start_val = inferred.value if inferred else None -+ # inferred can be an astroid.base.Instance as in 'enumerate(x, int(y))' or -+ # not correctly inferred (None) -+ start_val = inferred.value if isinstance(inferred, nodes.Const) else None - return start_val, INFERENCE - if isinstance(node, nodes.UnaryOp): - return node.operand.value, HIGH -diff --git a/tests/functional/u/unnecessary/unnecessary_list_index_lookup.py b/tests/functional/u/unnecessary/unnecessary_list_index_lookup.py -index 3201d5407d..b9f8b73251 100644 ---- a/tests/functional/u/unnecessary/unnecessary_list_index_lookup.py -+++ b/tests/functional/u/unnecessary/unnecessary_list_index_lookup.py -@@ -156,3 +156,14 @@ def _get_extra_attrs(self, extra_columns): - for idx, val in enumerate(my_list): - if (val := 42) and my_list[idx] == 'b': - print(1) -+ -+def regression_9078(apples, cant_infer_this): -+ """Regression test for https://github.com/pylint-dev/pylint/issues/9078.""" -+ for _, _ in enumerate(apples, int(cant_infer_this)): -+ ... -+ -+def random_uninferrable_start(pears): -+ import random # pylint: disable=import-outside-toplevel -+ -+ for _, _ in enumerate(pears, random.choice([5, 42])): -+ ... diff --git a/pylint-3.2.3.tar.gz b/pylint-3.2.3.tar.gz deleted file mode 100644 index 693061777ae803c3e0ac31b20aa820223df0a99f..0000000000000000000000000000000000000000 Binary files a/pylint-3.2.3.tar.gz and /dev/null differ diff --git a/pylint-3.3.1.tar.gz b/pylint-3.3.1.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..2623cf3e631066fafefce3558084976eb1f84958 Binary files /dev/null and b/pylint-3.3.1.tar.gz differ diff --git a/pylint.spec b/pylint.spec index f3b2c26ed55434b052f337c7b966892e94090515..5d6bd45da74be6259bf77c67778edfe710f132d4 100644 --- a/pylint.spec +++ b/pylint.spec @@ -1,13 +1,9 @@ Name: pylint -Version: 3.2.3 -Release: 2 +Version: 3.3.1 +Release: 1 Summary: Analyzes Python code looking for bugs and signs of poor quality -License: GPLv2+ +License: GPL-2.0-or-later URL: http://www.pylint.org/ - -Patch1: backport-Fix-crashes-for-uninferrable-start-value-in-enumerate.patch -Patch2: backport-Fix-a-crash-for-undefined-lineno-in-annotations.patch - Source0: https://github.com/pylint-dev/%{name}/archive/v%{version}/%{name}-%{version}.tar.gz BuildArch: noarch @@ -69,8 +65,6 @@ Additionally, it is possible to write plugins to add your own checks. %prep %autosetup -p1 -n pylint-%{version} -# Fix "similar -d args" not recognized -sed -i 's/s_opts = "hdi"/s_opts = "hd:i"/g' pylint/checkers/similar.py %build %pyproject_build @@ -102,6 +96,9 @@ done %{_bindir}/*-%{python3_version} %changelog +* Sun Sep 29 2024 wangkai <13474090681@163.com> - 3.3.1-1 +- Update to 3.3.1 + * Mon Aug 5 2024 zhangxingrong - 3.2.3-2 - Fix crashes for uninferrable 'start' value in 'enumerate' - Fix a crash for undefined lineno in annotations