Skip to content

Commit

Permalink
update mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasertl committed Sep 9, 2023
1 parent 85603b2 commit c73d6f4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ca/django_ca/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions ca/django_ca/tests/base/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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."""
Expand All @@ -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."""
Expand All @@ -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))


Expand Down
5 changes: 3 additions & 2 deletions requirements/requirements-mypy.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit c73d6f4

Please sign in to comment.