Support from typing import ClassVar#367
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.
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