From c73d6f4ca0abd6f3849018b1e36bf76c31ad3d8f Mon Sep 17 00:00:00 2001 From: Mathias Ertl Date: Sat, 9 Sep 2023 13:18:29 +0200 Subject: [PATCH] update mypy --- ca/django_ca/admin.py | 2 +- ca/django_ca/tests/base/mixins.py | 10 +++++----- requirements/requirements-mypy.txt | 5 +++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ca/django_ca/admin.py b/ca/django_ca/admin.py index 14398bafa..d9f56be11 100644 --- a/ca/django_ca/admin.py +++ b/ca/django_ca/admin.py @@ -169,7 +169,7 @@ def _download_response(self, request: HttpRequest, pk: int, bundle: bool = False # get object in question try: - obj = self.model.objects.get(pk=pk) + obj = self.model._default_manager.get(pk=pk) except self.model.DoesNotExist as ex: raise Http404 from ex diff --git a/ca/django_ca/tests/base/mixins.py b/ca/django_ca/tests/base/mixins.py index 9cec0355c..2314e33fa 100644 --- a/ca/django_ca/tests/base/mixins.py +++ b/ca/django_ca/tests/base/mixins.py @@ -1092,7 +1092,7 @@ def setUp(self) -> None: super().setUp() self.user = self.create_superuser() self.client.force_login(self.user) - self.obj = self.model.objects.first() # type: ignore[assignment] # TODO: get rid of this + self.obj = self.model._default_manager.all()[0] @property def add_url(self) -> str: @@ -1160,7 +1160,7 @@ def get_change_view( def get_objects(self) -> Iterable[DjangoCAModelTypeVar]: """Get list of objects for defined for this test.""" - return self.model.objects.all() + return self.model._default_manager.all() def get_url(self, obj: DjangoCAModelTypeVar) -> str: """Get URL for the given object for this test case.""" @@ -1180,11 +1180,11 @@ def get_changelists( Should yield tuples of objects that should be displayed and a dict of query parameters. """ - yield self.model.objects.all(), {} + yield self.model._default_manager.all(), {} def test_model_count(self) -> None: """Test that the implementing TestCase actually creates some instances.""" - self.assertGreater(self.model.objects.all().count(), 0) + self.assertGreater(self.model._default_manager.all().count(), 0) def test_changelist_view(self) -> None: """Test that the changelist view works.""" @@ -1193,7 +1193,7 @@ def test_changelist_view(self) -> None: def test_change_view(self) -> None: """Test that the change view works for all instances.""" - for obj in self.model.objects.all(): + for obj in self.model._default_manager.all(): assert_change_response(self.get_change_view(obj)) diff --git a/requirements/requirements-mypy.txt b/requirements/requirements-mypy.txt index 01215e3a6..204fc03d3 100644 --- a/requirements/requirements-mypy.txt +++ b/requirements/requirements-mypy.txt @@ -1,9 +1,10 @@ -r requirements-dev-common.txt +django-stubs==4.2.3 -r requirements-test.txt # mypy==1.5.0 breaks django-stubs==4.2.3: # https://github.com/typeddjango/django-stubs/issues/1648 -mypy==1.4.1 -django-stubs==4.2.3 +mypy==1.5.1 +django-stubs==4.2.4 types-docutils==0.20.0.3 types-freezegun==1.1.10 types-jinja2==2.11.9