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

Fix a crash when a subclass extends __slots__ #9817

Merged
merged 1 commit into from
Jul 20, 2024

Conversation

jacobtylerwalls
Copy link
Member

Type of Changes

Type
βœ“ πŸ› Bug fix

Description

Closes #9814

@jacobtylerwalls jacobtylerwalls added this to the 3.2.6 milestone Jul 20, 2024
slots_names: list[str] = []
try:
inferred_slots = tuple(node.ilookup("__slots__"))
except astroid.InferenceError: # pragma: no cover
Copy link
Member Author

@jacobtylerwalls jacobtylerwalls Jul 20, 2024

Choose a reason for hiding this comment

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

This is no-covered because the calls to this function are (currently) guarded by _has_valid_slots(), which does the same test, but just adding safety because we shouldn't be failing to catch InferenceError from calls to the inference system.

Copy link
Contributor

πŸ€– According to the primer, this change has no effect on the checked open source code. πŸ€–πŸŽ‰

This comment was generated for commit fcf9cf4

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

Great!

@jacobtylerwalls jacobtylerwalls enabled auto-merge (squash) July 20, 2024 14:15
@jacobtylerwalls jacobtylerwalls merged commit 8e18fc0 into main Jul 20, 2024
42 checks passed
@jacobtylerwalls jacobtylerwalls deleted the jtw/fix-slots-crash branch July 20, 2024 14:41
Copy link
Contributor

The backport to maintenance/3.2.x failed:

The process '/usr/bin/git' failed with exit code 1

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-9817-to-maintenance/3.2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 8e18fc012a5fcbd6cfe2b719e35ecd995da9f4bf
# Push it to GitHub
git push --set-upstream origin backport-9817-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 base branch is maintenance/3.2.x and the compare/head branch is backport-9817-to-maintenance/3.2.x.

jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this pull request Jul 20, 2024
jacobtylerwalls added a commit to jacobtylerwalls/pylint that referenced this pull request Jul 20, 2024
Pierre-Sassoulas added a commit that referenced this pull request Jul 20, 2024
(cherry picked from commit 8e18fc0)

Co-authored-by: Pierre Sassoulas <[email protected]>
Copy link

codecov bot commented Oct 18, 2024

Codecov Report

All modified and coverable lines are covered by tests βœ…

Project coverage is 95.79%. Comparing base (6236b91) to head (fcf9cf4).
Report is 123 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #9817   +/-   ##
=======================================
  Coverage   95.79%   95.79%           
=======================================
  Files         174      174           
  Lines       18902    18912   +10     
=======================================
+ Hits        18107    18117   +10     
  Misses        795      795           
Files with missing lines Coverage Ξ”
pylint/checkers/classes/class_checker.py 93.75% <100.00%> (+0.06%) ⬆️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weird __slots__ manip causes pylint to crash
2 participants