Skip to content

Documentation for attr support #4632

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

Merged
merged 4 commits into from
Feb 26, 2018
Merged

Documentation for attr support #4632

merged 4 commits into from
Feb 26, 2018

Conversation

euresti
Copy link
Contributor

@euresti euresti commented Feb 25, 2018

No description provided.

@euresti
Copy link
Contributor Author

euresti commented Feb 25, 2018

I don't know if this is the right place for it, or into how much detail I should go. Let me know!

@emmatyping
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to using method definition. Which seems to be what most of the documentation uses.

@euresti
Copy link
Contributor Author

euresti commented Feb 25, 2018

Thanks for the quick review. I moved it to the new section.

two: int = 7
three: int = attr.ib(8)

The Typeshed has a couple of "white lie" annotations to make type checking
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

@emmatyping emmatyping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good now.

@gvanrossum gvanrossum merged commit c594761 into python:master Feb 26, 2018
@gvanrossum
Copy link
Member

Yay! Thanks. Now we need to clone this for @dataclass(...) in Python 3.7...

carljm added a commit to carljm/mypy that referenced this pull request Feb 28, 2018
* 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)
  ...
yedpodtrzitko pushed a commit to kiwicom/mypy that referenced this pull request Mar 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants