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

Prevent dataclass parsing from triggering DuplicateBasesError #2629

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AleksMat
Copy link

Type of Changes

Type
βœ“ πŸ› Bug fix

Description

This PR prevents a crash described in #2628.

The dataclass parsing process in brain/brain_dataclasses.py calls ClassDef.mro method multiple times. Each time it can happen that the call raises DuplicateBasesError (even if bases aren't really duplicated). Because this happens in parsing and not in the linting part, Pylint doesn't catch DuplicateBasesError. This causes Pylint to crash.

The proposed solution is to add a flag to ClassDef.mro to ignore duplicate bases of the same base class. The PR also updates unit tests to verify the correct behavior.

Closes #2628

@Pierre-Sassoulas Pierre-Sassoulas added Needs review πŸ” Needs to be reviewed by one or multiple more persons Crash πŸ’₯ labels Oct 28, 2024
@Pierre-Sassoulas Pierre-Sassoulas added this to the 3.3.6 milestone Oct 28, 2024
Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

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

See my response in #2628 (comment)

I don't think this is the right solution and we should in fact try and understand if it is indeed Protocol that ends up twice, and if so, make sure to remove it and not consider it duplicate. Not by just ignoring the case but by determining a heuristic on which we can reliably consider it non-duplicate.

@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 3.3.6, 3.3.7 Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Crash πŸ’₯ Needs review πŸ” Needs to be reviewed by one or multiple more persons
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ast conversion for a dataclass raises DuplicateBasesError which crashes Pylint
3 participants