-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Why I get a TypeError: requires a single type | ||
============================================= | ||
|
||
The full error message looks something like this: | ||
|
||
.. code-block:: | ||
TypeError: typing.Optional requires a single type. Got Field(name=None,type=None,default=<dataclasses._MISSING_TYPE object at 0x7f79f4b0d700>,default_facto. | ||
The error means the dataclass wrapper can't build the typing annotations for a model | ||
because the field type is ambiguous. If you are using the code generator make sure you | ||
are not using the same convention for both field and class names. | ||
|
||
**Example** | ||
|
||
.. code-block:: python | ||
@dataclass | ||
class unit: | ||
pass | ||
@dataclass | ||
class element: | ||
unit: Optional[unit] = field() | ||
Read :ref:`more <Generator Config>` |