Skip to content

Commit

Permalink
Document behaviour with type checkers (fixes #91)
Browse files Browse the repository at this point in the history
  • Loading branch information
oxan committed Dec 25, 2023
1 parent 0e4c1b8 commit c37616a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -593,3 +593,18 @@ module that contains the extension.

.. _`drf-spectacular`: https://github.com/tfranzel/drf-spectacular
.. _`extension`: https://github.com/tfranzel/drf-spectacular/blob/master/drf_spectacular/contrib/rest_framework_dataclasses.py

Typing
------
When using a type checker such as mypy, please ensure that the ``djangorestframework-stubs`` package is installed. The
type hints for this library depend on the type hints for DRF being available to validate successfully, and might
otherwise generate some seemingly bizarre mypy errors.

The ``DataclassSerializer`` class is generic, and must be parameterized with the dataclass type to have correct types on
its properties and methods:

.. code:: Python
class PersonSerializer(DataclassSerializer[Person]):
class Meta:
dataclass = Person

0 comments on commit c37616a

Please sign in to comment.