Skip to content

Set slots_default for better ty support - #1649

Merged
hynek merged 1 commit into
python-attrs:mainfrom
AA-Turner:ty-slots_default
Oct 24, 2026
Merged

hynek merged 1 commit into
python-attrs:mainfrom
AA-Turner:ty-slots_default

Conversation

@AA-Turner

@AA-Turner AA-Turner commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Improve attrs support in the ty type checker by defining the slots_default parameter of the dataclass_transform decorator.

xref:

Also bumped the ty version in the lockfile to a version that has the linked PR, and the pyrefly version // removed the UV exclusion.

I haven't added a changelog entry as this is a pure stubs-only change, but happy to do so if you'd like!

A

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 (files ending in .pyi).
    • ...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 versionadded, versionchanged, or deprecated directives.
      The next version is the second number in the current release + 1.
      The first number represents the current year.
      So if the current version on PyPI is 26.2.0, the next version is gonna be 26.3.0.
      If the next version is the first in the new year, it'll be 27.1.0.
    • Documentation in .rst and .md files is written using semantic newlines.
  • Changes have news fragments in changelog.d.

@hynek hynek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A PR by a human! 🥹

I hope other type checkers don’t choke on the extra argument, but since they’re all passing I hope for the best…

@hynek
hynek added this pull request to the merge queue Oct 24, 2026
Merged via the queue into python-attrs:main with commit c8bb9bf Oct 24, 2026
17 checks passed
@AA-Turner
AA-Turner deleted the ty-slots_default branch October 25, 2026 00:47
@AA-Turner

Copy link
Copy Markdown
Contributor Author

Thanks @hynek! Human for now, at least...!

A

@carljm

carljm commented Oct 25, 2026

Copy link
Copy Markdown

I hope other type checkers don’t choke on the extra argument, but since they’re all passing I hope for the best…

@dataclass_transform was specified to accept **kwargs in order to allow experiments to extend it without causing this problem.

But I definitely think we should standardize slots_default. I doubt there will be any objections, I just need to find the time to propose the spec addition.

Thank you for taking this change!

@hynek

hynek commented Oct 25, 2026

Copy link
Copy Markdown
Member

Thanks Carl, good to know! I’ll have to gather strength and mop up the slop here before a release. 🙈

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.

3 participants