Skip to content

fix: preserve explicitly declared slots - #1648

Open
Samuel-Hills wants to merge 4 commits into
python-attrs:mainfrom
Samuel-Hills:fix-preserve-declared-slots-1637
Open

Samuel-Hills wants to merge 4 commits into
python-attrs:mainfrom
Samuel-Hills:fix-preserve-declared-slots-1637

Conversation

@Samuel-Hills

Copy link
Copy Markdown

Summary

attrs currently drops slots declared directly on a slotted attrs-decorated class when it creates the replacement class. As a result, assigning to one of those declared slots raises a TypeError.

This change preserves explicitly declared slots while retaining attrs-managed fields. It also adds a regression test and changelog entry.

Fixes #1637.

Validation

  • Full attrs test suite: 1406 passed, 6 skipped, 1 xfailed
  • git diff --check: passed

Pull Request Checklist

  • I acknowledge this project's AI policy.
  • This pull request is not from my main branch.
  • There's tests for all new and changed code.
  • Changes or additions to public APIs are reflected in our type stubs.
    • ...and used in the stub test file typing_tests/baseline.py or, if necessary, typing_tests/mypy.py.
    • If they've been added to attr/__init__.pyi, they've also been re-imported in attrs/__init__.pyi.
  • The documentation has been updated.
    • New functions/classes have to be added to docs/api.rst by hand.
    • Changes to the signatures of @attr.s() and @attrs.define() have to be added by hand too.
    • Changed/added classes/methods/functions have appropriate version directives.
    • Documentation uses semantic newlines.
  • Changes have news fragments in changelog.d.

This branch has not been deployed

No deployments
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.

slots declared on attrs-decorated class are ignored/lost

1 participant