Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport maintenance/3.2.x] Fix crash in refactoring checker when calling bound lambda #9867

Conversation

jacobtylerwalls
Copy link
Member

Manual backport of b78deb6 from #9866

@jacobtylerwalls jacobtylerwalls added this to the 3.2.7 milestone Aug 11, 2024
@jacobtylerwalls jacobtylerwalls changed the title Fix crash in refactoring checker when calling bound lambda [Backport maintenance/3.2.x] Fix crash in refactoring checker when calling bound lambda Aug 11, 2024
Copy link
Contributor

@Hnasar Hnasar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

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 pylint-dev#9865

(cherry picked from commit b78deb6)
@jacobtylerwalls jacobtylerwalls force-pushed the backport-9866-to-maintenance/3.2.x branch from 3ff6ca7 to 930ad78 Compare August 11, 2024 14:00
@jacobtylerwalls jacobtylerwalls merged commit f1925f4 into pylint-dev:maintenance/3.2.x Aug 11, 2024
21 checks passed
@jacobtylerwalls jacobtylerwalls deleted the backport-9866-to-maintenance/3.2.x branch August 11, 2024 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants