Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing type annotations for PEP 561 typed package #146

Open
johnthagen opened this issue Jul 1, 2021 · 0 comments
Open

Missing type annotations for PEP 561 typed package #146

johnthagen opened this issue Jul 1, 2021 · 0 comments

Comments

@johnthagen
Copy link
Contributor

#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:

def save(self, **kwargs):
self._save_kwargs = defaultdict(dict, kwargs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant