Skip to content

Commit c37616a

Browse files
committed
Document behaviour with type checkers (fixes #91)
1 parent 0e4c1b8 commit c37616a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

README.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,3 +593,18 @@ module that contains the extension.
593593

594594
.. _`drf-spectacular`: https://github.com/tfranzel/drf-spectacular
595595
.. _`extension`: https://github.com/tfranzel/drf-spectacular/blob/master/drf_spectacular/contrib/rest_framework_dataclasses.py
596+
597+
Typing
598+
------
599+
When using a type checker such as mypy, please ensure that the ``djangorestframework-stubs`` package is installed. The
600+
type hints for this library depend on the type hints for DRF being available to validate successfully, and might
601+
otherwise generate some seemingly bizarre mypy errors.
602+
603+
The ``DataclassSerializer`` class is generic, and must be parameterized with the dataclass type to have correct types on
604+
its properties and methods:
605+
606+
.. code:: Python
607+
608+
class PersonSerializer(DataclassSerializer[Person]):
609+
class Meta:
610+
dataclass = Person

0 commit comments

Comments
 (0)