-
-
Notifications
You must be signed in to change notification settings - Fork 408
Description
Originally posted by @euresti in #668 (comment)
I'm working on the mypy plugin but I am gonna need to know the final answer on how "hybrid" mode wants to work if there are both annotations and attribs. I think the options are:
- Take only the ones that have
= attr.ib() - Take only the annotated ones.
- Take both.
- Raise an exception.
Hmm. I thought #3 would be easy to implement (just don't raise the error) but it turns out we can't tell the order between annotated and un-annotated attributes.
class A:
x: int
y = attr.ib()
cls.__annotations__ -> [x]
cls.__dict__.keys(). -> [y]
But which is actually first?
#2 is kind of a weird one. Why throw away those attr.ib()s?
#1 is relatively easy to implement. Because it's just a try catch.
#4 Might require the user to add ClassVar in order to add it.
Oh I should note that I think this should still be fine:
@define
class A:
x: int = field()
y = field()
We shouldn't force you to have to annotate everything.
Hmm. That might make 4 harder to implement. :)