8000 Fix error when using slots with multiple inheritance by hmvp · Pull Request #2989 · pydantic/pydantic · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@hmvp
Copy link
Contributor
@hmvp hmvp commented Jul 16, 2021

Change Summary

Using PrivateAttr with multiple inheritance does not work because of the use of __slots__. The current code sets all parent private attrs again on any child thus overwriting the parent slots. Functionally that is not really an issue but it breaks the algorithm which determines if base classes clash with multiple inheritance

Related issue number

closes #2988

Checklist

  • Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • Documentation reflects the changes where applicable
  • changes/<pull request or issue id>-<github username>.md file added describing change
    (see changes/README.md for details)
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

@hmvp hmvp force-pushed the multiple_inheritance branch from c96433d to 3694339 Compare July 16, 2021 12:17
@hmvp
Copy link
Contributor Author
hmvp commented Jul 16, 2021

Not sure why the fastapi tests fail but I given the error and my change I don't think they are related.

Please review

@hmvp hmvp force-pushed the multiple_inheritance branch from 437e2c0 to 491b3c5 Compare July 30, 2021 09:18
@hmvp
Copy link
Contributor Author
hmvp commented Jul 30, 2021

Rebased to fix unrelated fastapi GHA fail

Copy link
Collaborator
@PrettyWood PrettyWood left a comment

Choose a reason for hiding this comment

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

Great! Thank you so much 🙏

@PrettyWood PrettyWood merged commit 22849ee into pydantic:master Sep 4, 2021
jpribyl pushed a commit to liquet-ai/pydantic that referenced this pull request Oct 7, 2021
* Fix error when using slots with multiple inheritance

* typo

* typing

Co-authored-by: PrettyWood <em.jolibois@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using PrivateAttr with multiple inheritance does not work because of the use of __slots__

3 participants

0