beda-software / drf-writable-nested

Writable nested model serializer for Django REST Framework
Other
1.07k stars 116 forks source link

Missing type annotations for PEP 561 typed package #146

Open johnthagen opened 3 years ago

johnthagen commented 3 years ago

127 added the py.typed file to the package to make this a PEP 561 compliant package. This triggers mypy to look into this package and search for type annotations.

The problem is that the entire package was not update to have type hints, so a user that happens to use other methods other than were changed in #127 now gets mypy errors.

Consider:

from drf_writable_nested.serializers import WritableNestedModelSerializer

class MySerializer(WritableNestedModelSerializer):
    pass

a = MySerializer().save()
$ mypy --strict main.py
main.py:8: error: Call to untyped function "save" in typed context
Found 1 error in 1 file (checked 1 source file)

Because this method was not annotated:

https://github.com/beda-software/drf-writable-nested/blob/c6c47e448d25458081f94e387235c51b8f9b9097/drf_writable_nested/mixins.py#L229-L230