mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-25 11:04:04 +03:00
Add djangorestframework-stubs
Add djangorestframework-stubs to local.txt requirements Modify setup.cfg to add stubs to mypy settings Fix new type error in DRF `./users/api/views.py:19: error: Incompatible type for lookup 'id': (got "Union[AutoField[Union[Combinable, int, str], int], Any]", expected "Union[str, int]")` by asserting that `self.request.user.id` is an int
This commit is contained in:
parent
c1484361a7
commit
00ff825b8c
|
@ -17,6 +17,9 @@ mypy==0.910 # https://github.com/python/mypy
|
|||
django-stubs==1.8.0 # https://github.com/typeddjango/django-stubs
|
||||
pytest==6.2.5 # https://github.com/pytest-dev/pytest
|
||||
pytest-sugar==0.9.4 # https://github.com/Frozenball/pytest-sugar
|
||||
{%- if cookiecutter.use_drf == "y" %}
|
||||
djangorestframework-stubs==1.4.0 # https://github.com/typeddjango/djangorestframework-stubs
|
||||
{%- endif %}
|
||||
|
||||
# Documentation
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -24,7 +24,7 @@ ignore_missing_imports = True
|
|||
warn_unused_ignores = True
|
||||
warn_redundant_casts = True
|
||||
warn_unused_configs = True
|
||||
plugins = mypy_django_plugin.main
|
||||
plugins = mypy_django_plugin.main{% if cookiecutter.use_drf == "y" %}, mypy_drf_plugin.main{% endif %}
|
||||
|
||||
[mypy.plugins.django-stubs]
|
||||
django_settings_module = config.settings.test
|
||||
|
|
|
@ -16,6 +16,7 @@ class UserViewSet(RetrieveModelMixin, ListModelMixin, UpdateModelMixin, GenericV
|
|||
lookup_field = "username"
|
||||
|
||||
def get_queryset(self, *args, **kwargs):
|
||||
assert isinstance(self.request.user.id, int)
|
||||
return self.queryset.filter(id=self.request.user.id)
|
||||
|
||||
@action(detail=False, methods=["GET"])
|
||||
|
|
Loading…
Reference in New Issue
Block a user