You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sure @ericvsmith, but the example in the documentation doesn't run.
Your suggestion for using list instead of list works, as long it is defined as x: list = field(default_factory=list).
However, I think the example is about forcing the datatype in the list using List from typing.
This works (as example only):
from dataclasses import dataclass
from typing import List
@dataclass
class User:
x: list = field(default_factory=list)
y: List[int] = field(default_factory=list)
this doesn't work
from dataclasses import dataclass
@dataclass
class User:
x: list = []
Documentation
Found that the typing
List
is used in example, but import is missed atdataclasses.rst
file.In this example:
the import
from typing import List
is missingThe text was updated successfully, but these errors were encountered: