-
-
Notifications
You must be signed in to change notification settings - Fork 386
Allow setting an annotation for attr.ib #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Currently this only has two effects: * It adds types to __init__ * It exposes the annotation on the attribute object itself It would be nice to propagate this further, but there isn't apparently a standard way to do that.
Codecov Report
@@ Coverage Diff @@
## master #162 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 8 8
Lines 551 561 +10
Branches 122 125 +3
=====================================
+ Hits 551 561 +10
Continue to review full report at Codecov.
|
Note that
Here Generally, it's not clear to me what your use case is. There's two issues. No type checker understands So in the end I believe an approach that uses regular type annotations will be more practical for the purposes of type checking. |
After some contemplation, I think this approach is basically complimentary to #151 and am OK with it being merged in. My idea was to take the variable annotation and stick it in Now, another thing accomplished here is setting the annotations on the generated The problem with this is a lot of Python builtins have no type signatures, so inspecting the converter will fail for easy cases like I have also considered whether creating another |
I’ll be staying mostly out of these discussions because I’m still not up to speed but I’d like to state for posterity that |
So this is basically #215 just with different field names, right? I think I’m going to close this if I understand correctly. |
sorry, I haven't had much time to give to this recently. I've no problem with you closing it. |
That wasn't my question but I’ll go ahead. Thanks for contributing mindshare to this non-trivial and emerging topic. |
This is a somewhat speculative pull request to gauge interest. It adds an additional annotation parameter to attr.ib for use with Python 3 type annotations.
Currently this only has two effects:
It would be nice to propagate this further, but there isn't apparently a standard way to do that
My use case is that I'm considering how one might make more things easy to generate out of the box, and having annotations on init helps a lot for that.