Done
7 / 77 of 7 issues completedLabels
attrsdataclassesIssues relating to dataclasses and dataclass_transformlibraryDedicated support for popular third-party libraries
Description
No description provided.
Reacted by Jonathan Berthias, Matthias Mair, Matthew Vine, 93578237, Andy Dai, Bryan C. Mills, AdrianSosic, my1e5, Mert Can Demir, Andy Freeland and 19 more
Reacted by Hynek Schlawack, Nick, my1e5, Mert Can Demir, Andy Freeland, Valentin Stauber, ZuidVolt, Jorge Gomez, Rainer Poisel and Adam Turner
Sub-issues
Collapse Sub-issuesSub-issues
Loading 7 sub-issues
Metadata
Metadata
Assignees
Labels
attrsdataclassesIssues relating to dataclasses and dataclass_transformlibraryDedicated support for popular third-party libraries
Activity
_MISSING_TYPEis not callable for@<field>.defaultinattrsclass #1444hynek commentedon Jan 12, 2026
wow I came begging for one particular feature and found this late xmas present! 😻
LMK if you need any help/advice!
As a starter (and the reason I came here): could y'all implement attrs's underscore prefix stripping? 😇
I.e. defining an attribute called
_foocreates an__init__(self, foo)because there's no such thing as a private argument and you wouldn't call your argument that yourself either (this goes back to attrs's philosophy of helping you to write classes the way you would write them). This is currently by far my biggest annoyance with ty's LSP server.Should I open an subissue (hilariously I've never used that feature so not sure how)?
carljm commentedon Jan 13, 2026
Filed #2474!
Don't thank us too much until we actually do it! We currently have this slated for stable, but there's a lot of stuff slated for stable -- this might end up being a next-Christmas present 😆
my1e5 commentedon Feb 5, 2026
Thanks for opening this tracking issue! Just wanted to raise that
unresolved-attributefor@<field>.validatorinattrsclass #267should also be a sub-issue.
unresolved-attributefor@<field>.validatorinattrsclass #267ktbarrett commentedon Mar 9, 2026
#3008 is related.
typeargument inattr.ibinstead of annotations not supported #3008attrsfield decorators #3068yashovardhan99 commentedon Jun 22, 2026
If possible, can we add support for attrs custom init as well.
A small example:
9 remaining items
[ty] Support `__attrs_init__` on attrs classes with `init=False` (#30852
hynek commentedon Nov 26, 2026
I've ran ty 0.0.111 against the pyrefly and mypy typing tests and the things you mention are looking good – I think I'll be able to merge quite a bit into baseline!
The only things I've noticed are:
@x.converteris missing wholesale.Doesn't pass so it doesn't on pyrefly on 1.15 so dunno what is going on.
Ty caught an error in the type checks where we use multiple inheritance with slotted classes 🤓
I've decided to refactor the typing checks a bit: python-attrs/attrs#1670
Do you think there's anything missing?
Thanks again for tackling this!
hynek commentedon Nov 26, 2026
ah so, I've added a test regarding private attributes and it didn't work and it seems like Ty's attrs integration doesn't work if it's running inside the repo as a first-party package.
I have now worked around it by passing
ty check --config 'environment.root=[]'but could there be a nicer way? Are there any precedents within Ty?Work around ty's attrs detection
sharkdp commentedon Nov 26, 2026
Thank you for the feedback!
ty has support for converters for other dataclass-flavors, so
x: int = field(converer=...)should already work). We do not have support for@<field>.converteryet, but that shouldn't be too hard to add. It looks like this hasn't even been released as a feature of attrs, though, so you're asking us to support upcoming features of attrs? 😄(was that supposed to be
attrinstead ofattrsin one of the checks?)It looks like this could be fixed in attrs itself if this protocol was defined for ty as well. Then ty would understand the
TypeGuardhere and narrowfooaccordingly.And I guess ty would have to synthesize that
__attrs_attrs__attribute on attrs classes.Hooray? 😄
A larger feature that we haven't implemented is support for unannotated fields, e.g.:
I have a draft PR up for adding support, but it doesn't fit naturally into ty's architecture, unfortunately. Do you think that this is important to support?
Oh, yes. This is sort-of intentional. If a user has a module named
attr(s)in their first-part source code, we don't want to start attributing any special behavior to symbols inside those modules. It could be worked around by moving the typing tests to a separate package, or by using something like you did, or maybe:because we consider
extra-pathsto potentially contain 3rd party code.sharkdp commentedon Nov 26, 2026
I guess it's not easily possible to distinguish ty from other type checkers right now. I was planning to propose a change to python/typing, e.g. a
TYPE_CHECKER_NAMEvariable, that would allow library authors to identify type-checkers in a standardized way. But that's a long-term thing, so for now I will just add support for__attrs_attrs__/AttrsInstanceto ty itself: astral-sh/ruff#30958sharkdp commentedon Nov 26, 2026
astral-sh/ruff#30959
hynek commentedon Nov 26, 2026
Ha, I kinda lost track! This was one of the features that fell a bit off the wagon because Pyright/Pylance sucked all the air out of the ecosystem and there was little reason to implement new features. :( I'll come back once I released a new version; guess I finally have a reason to wade thru all the slop PRs. 🤢
I do not. That was mostly a compat feature back in the 2.x times. I don't think they're widely used in maintained software.
yay much cleaner: python-attrs/attrs@a5c6c87
So I understand all I have to do is fixing the attr.has typo and wait for a ty release?
[ty] attrs: Support `__attrs_attrs__` and the `AttrsInstance` protocol (
[ty] attrs: Support field converter decorators (#30959)
sharkdp commentedon Nov 26, 2026
No worries. This is implemented in ty now, so whenever attrs releases this feature, it should already work in ty.
Ok, good. In this case, I'm choosing not to implement support for this in ty.
Yes, here you go: https://github.com/astral-sh/ty/releases/tag/0.0.112
sharkdp commentedon Nov 26, 2026
I think this completes attrs support for now. Everyone, please feel free to file new issues (or comment here) if a feature seems to be missing or if something isn't working correctly.
Refactor typing tests (#1670)
AdrianSosic commentedon Nov 27, 2026
Hi @sharkdp, I think I found another false positive. While the converters/validators work in isolation, it seems that their interaction is not yet handled correctly. Here a minimal example.
Let me know if I should open a separate issue for it 👍🏼