diff --git a/hc/accounts/backends.py b/hc/accounts/backends.py index 85cce147..4ae0ff4d 100644 --- a/hc/accounts/backends.py +++ b/hc/accounts/backends.py @@ -8,7 +8,7 @@ from hc.accounts.models import Profile from hc.accounts.views import _make_user -class BasicBackend(object): +class BasicBackend: def get_user(self, user_id: int) -> User | None: try: q = User.objects.select_related("profile") diff --git a/hc/accounts/middleware.py b/hc/accounts/middleware.py index fdc9c9ad..468e60a7 100644 --- a/hc/accounts/middleware.py +++ b/hc/accounts/middleware.py @@ -13,7 +13,7 @@ from hc.accounts.models import Profile MiddlewareFunc = Callable[[HttpRequest], HttpResponse] -class TeamAccessMiddleware(object): +class TeamAccessMiddleware: def __init__(self, get_response: MiddlewareFunc) -> None: self.get_response = get_response @@ -25,7 +25,7 @@ class TeamAccessMiddleware(object): return self.get_response(request) -class CustomHeaderMiddleware(object): +class CustomHeaderMiddleware: """ Middleware for utilizing Web-server-provided authentication. diff --git a/hc/api/models.py b/hc/api/models.py index f1eb0d80..d66e96ff 100644 --- a/hc/api/models.py +++ b/hc/api/models.py @@ -149,7 +149,7 @@ class DowntimeRecord: return up_seconds / max_seconds -class DowntimeRecorder(object): +class DowntimeRecorder: def __init__(self, boundaries: list[datetime], tz: str, created: datetime) -> None: """ `boundaries` is a list of timezone-aware datetimes of the starts of time diff --git a/hc/api/tests/test_notify_signal.py b/hc/api/tests/test_notify_signal.py index 31ce30d9..9c44b798 100644 --- a/hc/api/tests/test_notify_signal.py +++ b/hc/api/tests/test_notify_signal.py @@ -1,5 +1,3 @@ -# coding: utf-8 - from __future__ import annotations import json @@ -21,7 +19,7 @@ from hc.test import BaseTestCase Address = str | tuple[str, int] -class MockSocket(object): +class MockSocket: def __init__( self, response_tmpl: Any, side_effect: Exception | None = None ) -> None: diff --git a/hc/api/transports.py b/hc/api/transports.py index dbed75f3..b0cf065c 100644 --- a/hc/api/transports.py +++ b/hc/api/transports.py @@ -80,7 +80,7 @@ class TransportError(Exception): self.permanent = permanent -class Transport(object): +class Transport: def __init__(self, channel: Channel): self.channel = channel diff --git a/hc/front/tests/test_signal_captcha.py b/hc/front/tests/test_signal_captcha.py index 7767e03c..a468a3d9 100644 --- a/hc/front/tests/test_signal_captcha.py +++ b/hc/front/tests/test_signal_captcha.py @@ -1,5 +1,3 @@ -# coding: utf-8 - from __future__ import annotations import json @@ -14,7 +12,7 @@ from hc.test import BaseTestCase Address = str | tuple[str, int] -class MockSocket(object): +class MockSocket: def __init__(self, response_tmpl: dict[str, str]) -> None: self.response_tmpl = response_tmpl self.req = None diff --git a/hc/front/validators.py b/hc/front/validators.py index 720c92f5..04fa3a41 100644 --- a/hc/front/validators.py +++ b/hc/front/validators.py @@ -29,7 +29,7 @@ class WebhookValidator(URLValidator): super().__call__(self.add_tld(value)) -class CronValidator(object): +class CronValidator: message = "Not a valid cron expression." def __call__(self, value: str) -> None: @@ -46,7 +46,7 @@ class CronValidator(object): raise ValidationError(message=self.message) -class OnCalendarValidator(object): +class OnCalendarValidator: message = "Not a valid OnCalendar expression." def __call__(self, value: str) -> None: @@ -64,7 +64,7 @@ class OnCalendarValidator(object): raise ValidationError(message=self.message) -class TimezoneValidator(object): +class TimezoneValidator: message = "Not a valid time zone." def __call__(self, value: str) -> None: diff --git a/hc/lib/curl.py b/hc/lib/curl.py index c25792fd..f8133464 100644 --- a/hc/lib/curl.py +++ b/hc/lib/curl.py @@ -29,7 +29,7 @@ class CurlError(Exception): self.message = message -class Response(object): +class Response: def __init__(self, status_code: int, content: bytes) -> None: self.status_code = status_code self.content = content diff --git a/hc/lib/date.py b/hc/lib/date.py index 405ecee1..bd12b7a6 100644 --- a/hc/lib/date.py +++ b/hc/lib/date.py @@ -6,7 +6,7 @@ from zoneinfo import ZoneInfo from django.utils.timezone import now -class Unit(object): +class Unit: def __init__(self, name: str, nsecs: int): self.name = name self.plural = name + "s" diff --git a/hc/lib/tests/test_curl.py b/hc/lib/tests/test_curl.py index e847cd48..2b305e40 100644 --- a/hc/lib/tests/test_curl.py +++ b/hc/lib/tests/test_curl.py @@ -10,7 +10,7 @@ from django.test.utils import override_settings from hc.lib.curl import CurlError, request -class FakeCurl(object): +class FakeCurl: def __init__(self, ip: str = "1.2.3.4") -> None: self.opts: dict[int, Any] = {} self.ip = ip diff --git a/hc/lib/webauthn.py b/hc/lib/webauthn.py index 366da523..21b77231 100644 --- a/hc/lib/webauthn.py +++ b/hc/lib/webauthn.py @@ -17,7 +17,7 @@ from fido2.webauthn import ( fido2.features.webauthn_json_mapping.enabled = True -class CreateHelper(object): +class CreateHelper: def __init__(self, rp_id: str, credentials: Iterable[bytes]): rp = PublicKeyCredentialRpEntity(id=rp_id, name="healthchecks") self.server = Fido2Server(rp) @@ -52,7 +52,7 @@ class CreateHelper(object): return auth_data.credential_data -class GetHelper(object): +class GetHelper: def __init__(self, rp_id: str, credentials: Iterable[bytes]): rp = PublicKeyCredentialRpEntity(id=rp_id, name="healthchecks") self.server = Fido2Server(rp)