Message346349
I tried a couple of the examples from the docs and found the setup to be a little confusing
amd inconsistent. For example, the decorator line "@decorator" requires you to use
from dataclasses import dataclass
while the example line "mylist: List[int] = field(default_factory=list)" requires you to use these
import dataclasses
import typing
and must be modified to
mylist: typing.List[int] = dataclasses.field(default_factory=list)
The decorator line could be modified to be
@dataclasses.dataclass
and the from/import line could be eliminated. But that seems awkward.
So, what is are best practices for handling the imports needed by these examples?
And should the examples be updated to be consistent with a best practice set of imports?
Or am I not understanding how this code works?
Also, the intro section states "If any of the added methods already exist on the class, a TypeError will be raised."
This statement seems incorrect and contrdicts the parameter documentation that follows. |
|
Date |
User |
Action |
Args |
2019-06-24 00:07:25 | mturner865 | set | recipients:
+ mturner865, brett.cannon, eric.smith, docs@python, matrixise, Windson Yang, xtreak, mfisherlevine |
2019-06-24 00:07:25 | mturner865 | set | messageid: <1561334845.35.0.979195736346.issue36661@roundup.psfhosted.org> |
2019-06-24 00:07:25 | mturner865 | link | issue36661 messages |
2019-06-24 00:07:25 | mturner865 | create | |
|