0
0
Fork 0
mirror of https://github.com/healthchecks/healthchecks.git synced 2025-04-14 08:58:29 +00:00

Fix lint issues

This commit is contained in:
Pēteris Caune 2023-07-12 13:44:35 +03:00
parent 774471e4e8
commit c4851f3b49
No known key found for this signature in database
GPG key ID: E28D7679E9A9EDE2
4 changed files with 13 additions and 13 deletions

View file

@ -135,7 +135,7 @@ class LargeTablePaginator(Paginator):
[self.object_list.query.model._meta.db_table], [self.object_list.query.model._meta.db_table],
) )
return int(cursor.fetchone()[0]) return int(cursor.fetchone()[0])
except: except Exception:
return 0 return 0
@cached_property @cached_property

View file

@ -19,21 +19,21 @@ From: "User Name" <username@gmail.com>
To: "John Smith" <john@example.com> To: "John Smith" <john@example.com>
Subject: %s Subject: %s
MIME-Version: 1.0 MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="=-eZCfVHHsxj32NZLHPpkbTCXb9C529OcJ23WKzQ==" Content-Type: multipart/alternative; boundary="marker"
--=-eZCfVHHsxj32NZLHPpkbTCXb9C529OcJ23WKzQ== --marker
Content-Type: text/plain; charset=utf-8 Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit Content-Transfer-Encoding: 7bit
Plain text here Plain text here
--=-eZCfVHHsxj32NZLHPpkbTCXb9C529OcJ23WKzQ== --marker
Content-Type: text/html; charset=utf-8 Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
%s %s
--=-eZCfVHHsxj32NZLHPpkbTCXb9C529OcJ23WKzQ==-- --marker--
""".strip() """.strip()

View file

@ -3,7 +3,7 @@ from __future__ import annotations
from datetime import datetime from datetime import datetime
from urllib.parse import urlsplit, urlunsplit from urllib.parse import urlsplit, urlunsplit
from cronsim import CronSim from cronsim import CronSim, CronSimError
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.core.validators import URLValidator from django.core.validators import URLValidator
@ -41,7 +41,7 @@ class CronExpressionValidator(object):
it = CronSim(value, datetime(2000, 1, 1)) it = CronSim(value, datetime(2000, 1, 1))
# Can it calculate the next datetime? # Can it calculate the next datetime?
next(it) next(it)
except: except (CronSimError, StopIteration):
raise ValidationError(message=self.message) raise ValidationError(message=self.message)

View file

@ -9,7 +9,7 @@ from __future__ import annotations
import re import re
from datetime import datetime from datetime import datetime
from cronsim import CronSim from cronsim import CronSim, CronSimError
from hc.lib.tz import all_timezones from hc.lib.tz import all_timezones
@ -29,16 +29,16 @@ def validate(obj, schema, obj_name="value"):
if "pattern" in schema and not re.match(schema["pattern"], obj): if "pattern" in schema and not re.match(schema["pattern"], obj):
raise ValidationError(f"{obj_name} does not match pattern") raise ValidationError(f"{obj_name} does not match pattern")
if schema.get("format") == "cron": if schema.get("format") == "cron":
try: # Does it have 5 components?
# Does it have 5 components? if len(obj.split()) != 5:
if len(obj.split()) != 5: raise ValidationError(f"{obj_name} is not a valid cron expression")
raise ValueError()
try:
# Does cronsim accept the schedule? # Does cronsim accept the schedule?
it = CronSim(obj, datetime(2000, 1, 1)) it = CronSim(obj, datetime(2000, 1, 1))
# Can it calculate the next datetime? # Can it calculate the next datetime?
next(it) next(it)
except: except (CronSimError, StopIteration):
raise ValidationError(f"{obj_name} is not a valid cron expression") raise ValidationError(f"{obj_name} is not a valid cron expression")
if schema.get("format") == "timezone" and obj not in all_timezones: if schema.get("format") == "timezone" and obj not in all_timezones:
raise ValidationError(f"{obj_name} is not a valid timezone") raise ValidationError(f"{obj_name} is not a valid timezone")