-
-
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.
Fix crash in refactoring checker when calling bound lambda
Fixes: ``` File "sources/pylint/pylint/checkers/refactoring/refactoring_checker.py", line 2094, in _is_function_def_never_returning and node.returns ^^^^^^^^^^^^ File "sources/pylint/.venv/lib/python3.11/site-packages/astroid/bases.py", line 138, in __getattr__ return getattr(self._proxied, name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'Lambda' object has no attribute 'returns' ``` Crash is reproducible if you have something like this: ```python class C: eq = lambda self, y: self == y ``` As a workaround, use a normal function instead of a lambda. Closes #9865
- Loading branch information
1 parent
466c671
commit b78deb6
Showing
3 changed files
with
21 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Fix crash in refactoring checker when calling a lambda bound as a method. | ||
|
||
Closes #9865 |
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
8 changes: 8 additions & 0 deletions
8
tests/functional/r/regression/regression_9865_calling_bound_lambda.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,8 @@ | ||
"""Regression for https://github.com/pylint-dev/pylint/issues/9865.""" | ||
# pylint: disable=missing-docstring,too-few-public-methods,unnecessary-lambda-assignment | ||
class C: | ||
eq = lambda self, y: self == y | ||
|
||
def test_lambda_method(): | ||
ret = C().eq(1) | ||
return ret |