Skip to content

Commit

Permalink
Add faq question #646
Browse files Browse the repository at this point in the history
  • Loading branch information
tefra committed Jan 29, 2022
1 parent fcc10b1 commit 16b12b6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/faq/why-i-get-a-typeerror-requires-a-single-type.rst
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>`

0 comments on commit 16b12b6

Please sign in to comment.