Skip to content

Commit

Permalink
Resolve 'mypy' linting errors (p2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonavellecuerdo committed Mar 6, 2024
1 parent 4dc0e53 commit 84503bd
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 16 deletions.
2 changes: 2 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pytest = "*"
pytest-django = "*"
requests-mock = "*"
ruff = "*"
types-beautifulsoup4 = "*"
types-requests = "*"

[packages]
# Only needed for Heroku
Expand Down
26 changes: 25 additions & 1 deletion Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 15 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,29 @@
line-length = 90

[tool.django-stubs]
django_settings_module = "solenoid.settings"
django_settings_module = "solenoid.settings.base"

[tool.mypy]
disallow_untyped_calls=true
disallow_untyped_defs=true
disallow_untyped_defs=false
exclude=[
"solenoid/wsgi.py",
"solenoid/accounts/migrations",
"solenoid/elements/migrations",
"solenoid/emails/migrations",
"solenoid/people/migrations/",
"solenoid/records/migrations/"
"^solenoid/.*/tests/.*",
"^solenoid/.*/migrations/.*",
"solenoid/wsgi.py"
]
plugins = ["mypy_django_plugin.main"]

[[tool.mypy.overrides]]
module = ["solenoid.elements.xml_handlers"]
disable_error_code = ["union-attr"]

[[tool.mypy.overrides]]
module = [
"celery_progress.backend",
"ckeditor.fields",
"ckeditor.widgets",
"debug_toolbar",
"environ"
]
ignore_missing_imports = true

12 changes: 6 additions & 6 deletions solenoid/people/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
# unending recursion, so we're following the suggestion in the documentation:
# https://docs.djangoproject.com/en/1.8/topics/db/queries/#deleting-objects
class ProtectiveQueryset(QuerySet):
def delete(self):
def delete(self): # type: ignore[no-untyped-def]
for obj in self.all():
obj.delete()


class DefaultManager(models.Manager):
def get_queryset(self):
def get_queryset(self) -> ProtectiveQueryset:
return ProtectiveQueryset(self.model, using=self._db)


class ActiveLiaisonManager(models.Manager):
def get_queryset(self):
def get_queryset(self) -> ProtectiveQueryset:
return ProtectiveQueryset(self.model, using=self._db).filter(active=True)


Expand All @@ -41,7 +41,7 @@ class Meta:
verbose_name_plural = "Liaisons"
ordering = ["last_name", "first_name"]

def __str__(self):
def __str__(self) -> str:
return "{self.first_name} {self.last_name}".format(self=self)

first_name = models.CharField(max_length=15)
Expand All @@ -59,9 +59,9 @@ def __str__(self):
# Liaisons.
objects = ActiveLiaisonManager()

def save(self, *args, **kwargs):
def save(self, *args, **kwargs) -> None:
if not self.active:
self.dlc_set.clear()
self.dlc_set.clear() # type: ignore[attr-defined]

return super(Liaison, self).save(*args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion solenoid/people/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def post(self, request, *args, **kwargs):
return self.form_invalid(form)


class LiaisonDelete(ConditionalLoginRequiredMixin, DeleteView):
class LiaisonDelete(ConditionalLoginRequiredMixin, DeleteView): # type: ignore[misc]
model = Liaison
queryset = Liaison.objects.all()

Expand Down

0 comments on commit 84503bd

Please sign in to comment.