Repository navigation
Refs #5383: Document that aliasing dataclass fails - #5387
Conversation
This documentation is a temporary solution. It should be altered or removed when python#5383 is fixed
gvanrossum
left a comment
There was a problem hiding this comment.
Thanks for submitting this.
Can you add a comment for each "badly decorated class" explaining what's wrong with its decoration? And please come up with better names than 1, 2, 3. What's fine to put in a bug report doesn't necessarily look right in the docs!
| return dataclass(cls) | ||
|
|
||
| @dataclass_alias | ||
| class BadlyDecoratedClass1: arg1: int |
There was a problem hiding this comment.
I didn't realize this syntax was legal. I think it's better to put the field on a separate line.
|
@wkschwartz Please respond to the review feedback. (Please use a new local commit, or several, to update your changes -- don't use |
|
|
||
| Mypy does not yet recognize aliases of ``dataclasses.dataclass``, and will | ||
| probably never recognize dynamically computed decorators. The following examples | ||
| do **not** work: |
There was a problem hiding this comment.
I would actually skip the examples, the textual formulation is already clear (except maybe the dynamically computed decorators).
- Rename example classes - Cut down on number of examples - Add comment to each example to explain what's wrong - Use more traditional code style
|
@ilevkivskyi I removed one of the three examples in response to #5387 (comment) in dc742c8 |
ilevkivskyi
left a comment
There was a problem hiding this comment.
Thanks! Looks almost ready now. Could you please fix one last comment and I will merge it.
| Mypy doesn't recognize this as a dataclass because it is decorated by an | ||
| alias of `dataclass` rather than by `dataclass` itself. | ||
| """ | ||
| arg1: int |
There was a problem hiding this comment.
Could you please use attr (or similar) instead of arg1?
This documentation is a temporary solution. It should be altered or
removed when #5383 is fixed.
I inserted the whole example from #5383. If you think that's too much, feel free to modify. I've granted edit permissions to maintainers.