0
0
Fork 0
mirror of https://github.com/healthchecks/healthchecks.git synced 2025-04-03 04:15:29 +00:00

Fix "class Foo(object):" -> "class Foo:"

In Python 3 these are equivalent, and shorter is better.
This commit is contained in:
Pēteris Caune 2024-10-29 17:57:50 +02:00
parent a6ca589b34
commit e048ec4c48
No known key found for this signature in database
GPG key ID: E28D7679E9A9EDE2
11 changed files with 15 additions and 19 deletions

View file

@ -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")

View file

@ -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.

View file

@ -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

View file

@ -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:

View file

@ -80,7 +80,7 @@ class TransportError(Exception):
self.permanent = permanent
class Transport(object):
class Transport:
def __init__(self, channel: Channel):
self.channel = channel

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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)