-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix crash in refactoring checker when calling bound lambda #9866
Conversation
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
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9866 +/- ##
=======================================
Coverage 95.80% 95.80%
=======================================
Files 174 174
Lines 18932 18936 +4
=======================================
+ Hits 18137 18141 +4
Misses 795 795
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the report and patch!
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-maintenance/3.2.x maintenance/3.2.x
# Navigate to the new working tree
cd .worktrees/backport-maintenance/3.2.x
# Create a new branch
git switch --create backport-9866-to-maintenance/3.2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 b78deb6140799549ae5f2afc9cb5bc8c1afda5cc
# Push it to GitHub
git push --set-upstream origin backport-9866-to-maintenance/3.2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-maintenance/3.2.x Then, create a pull request where the |
Fixes:
Crash is reproducible if you have something like this:
As a workaround, use a normal function instead of a lambda.
Closes #9865
Type of Changes