-
-
Notifications
You must be signed in to change notification settings - Fork 409
Support from typing import ClassVar
#367
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
Also updated the docstring to reflect why exactly we're doing what we're doing. The previous comment was incorrect (`typing` is already imported in applications using annotations). I added `t.ClassVar` as well which is the only third alternative import I found in use for typing-related classes. Fixes python-attrs#361
Codecov Report
@@ Coverage Diff @@
## master #367 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 9 9
Lines 830 831 +1
Branches 174 174
=====================================
+ Hits 830 831 +1
Continue to review full report at Codecov.
|
src/attr/_make.py
Outdated
| def _is_class_var(annot): | ||
| """ | ||
| Check whether *annot* is a typing.ClassVar. | ||
| """Check whether *annot* is a typing.ClassVar. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
src/attr/_make.py
Outdated
| disadvantage compared to plain old classes. | ||
| """ | ||
| return str(annot).startswith("typing.ClassVar") | ||
| return str(annot).startswith(("typing.ClassVar", "t.ClassVar", "ClassVar")) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
🏓 |
|
(updated) |
euresti
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Thanks!
|
Thanks everyone! At least we can feel bad about that hack together. ;) |
Also updated the docstring to reflect why exactly we're doing what we're doing.
The previous comment was incorrect (
typingis already imported inapplications using annotations).
I added
t.ClassVaras well which is the only third alternative import I foundin use for typing-related classes.
Fixes #361