Documentation for attr support#4632
Conversation
|
I don't know if this is the right place for it, or into how much detail I should go. Let me know! |
|
Hm, I don't consider attrs a Python feature per-se. I think attrs documentation would probably be a better fit for the additional features page. |
| two: int = 7 | ||
| three: int = attr.ib(8) | ||
|
|
||
| The typeshed has a couple of "white lie" annotations to make type checking |
There was a problem hiding this comment.
"The typeshed" -> "Typeshed", since there aren't other typesheds.
| two: Dict[str, str] = attr.Factory(dict) | ||
| bad: str = attr.ib(16) # Error: can't assign int to str | ||
|
|
||
| Caveats/Known Issues |
There was a problem hiding this comment.
Is this supposed to be made a section heading?
| and `default decorators <http://www.attrs.org/en/stable/examples.html#defaults>`_ | ||
| are not type-checked against the attribute they are setting/validating. | ||
|
|
||
| * Methods added by mypy currently overwrite any existing methods. This is how |
There was a problem hiding this comment.
This sounds like mypy is mutating things at runtime. AIUI, that is not the case. Perhaps re-wording to talk about mypy recognizing/understanding attrs generated methods throughout would avoid confusion?
There was a problem hiding this comment.
Switched to using method definition. Which seems to be what most of the documentation uses.
|
Thanks for the quick review. I moved it to the new section. |
docs/source/additional_features.rst
Outdated
| two: int = 7 | ||
| three: int = attr.ib(8) | ||
|
|
||
| The Typeshed has a couple of "white lie" annotations to make type checking |
There was a problem hiding this comment.
I might have been unclear (sorry), but I was mostly talking about removing the preceding article. Typeshed is a proper noun and the name is referred to without a preceding article everywhere else.
|
Yay! Thanks. Now we need to clone this for |
* master: (27 commits) Don't call --strict-optional and --incremental experimental (python#4642) Sync typeshed (python#4641) Fix callable types with inconsistent argument counts (python#4611) Fix example (add 'class A:') Make psutil an optional dependency (python#4634) mypy and mypy_extensions aren't posix only (python#3765) Documentation for attr support (python#4632) Use read_with_python_encoding in stubgen to handle file encoding (python#3790) Sync typeshed (python#4631) Add remaining core team emails to CREDITS (python#4629) Fix issues with attr code. (python#4628) Better support for converter in attrs plugin. (python#4607) Clean up credits (python#4626) Support type aliases in fine-grained incremental mode (python#4525) Fine-grained: Fix crash caused by unreachable class (python#4613) Treat divmod like a binary operator (python#4585) Sync typeshed (python#4605) Fine-grained: Don't infer partial types from multiple targets (python#4553) Fine-grained: Compare symbol table snapshots when following dependencies (python#4598) Fix type of forward reference to a decorated class method (python#4486) ...
No description provided.