upgrade flake8 to v7 (#4141)
# Which issue(s) this PR closes Fixes [this issue](https://github.com/grafana/oncall-private/pull/2620/files#diff-0144920543fd191db13f76c9fb797116e26eda2bdd2b79332b61bfbf5846208eR193-R197) (https://github.com/PyCQA/pycodestyle/issues/334#issuecomment-2027394413) in `grafana/oncall-private` ## Checklist - [ ] Unit, integration, and e2e (if applicable) tests updated (N/A) - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] Added the relevant release notes label (see labels prefixed w/ `release:`). These labels dictate how your PR will show up in the autogenerated release notes.
This commit is contained in:
parent
c1766d9fc2
commit
afc688feda
10 changed files with 20 additions and 20 deletions
|
|
@ -29,7 +29,7 @@ repos:
|
|||
files: ^dev/scripts
|
||||
|
||||
- repo: https://github.com/pycqa/flake8
|
||||
rev: 6.0.0
|
||||
rev: 7.0.0
|
||||
hooks:
|
||||
- id: flake8
|
||||
files: ^engine
|
||||
|
|
|
|||
|
|
@ -1889,11 +1889,11 @@ class AlertGroup(AlertGroupSlackRenderingMixin, EscalationSnapshotMixin, models.
|
|||
result_log_report = list()
|
||||
|
||||
for log_record in log_records_list:
|
||||
if type(log_record) == AlertGroupLogRecord:
|
||||
if type(log_record) is AlertGroupLogRecord:
|
||||
result_log_report.append(log_record.render_log_line_json())
|
||||
elif type(log_record) == UserNotificationPolicyLogRecord:
|
||||
elif type(log_record) is UserNotificationPolicyLogRecord:
|
||||
result_log_report.append(log_record.rendered_notification_log_line_json)
|
||||
elif type(log_record) == ResolutionNote:
|
||||
elif type(log_record) is ResolutionNote:
|
||||
result_log_report.append(log_record.render_log_line_json())
|
||||
return result_log_report
|
||||
|
||||
|
|
|
|||
|
|
@ -145,10 +145,10 @@ def test_list_alert_receive_channel_skip_pagination_for_grafana_alerting(
|
|||
assert response.status_code == status.HTTP_200_OK
|
||||
|
||||
if should_be_unpaginated:
|
||||
assert type(results) == list
|
||||
assert type(results) is list
|
||||
assert len(results) > 0
|
||||
else:
|
||||
assert type(results["results"]) == list
|
||||
assert type(results["results"]) is list
|
||||
assert len(results["results"]) > 0
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -443,7 +443,7 @@ class AlertReceiveChannelView(
|
|||
if payload is None:
|
||||
return channel.alert_groups.last().alerts.first()
|
||||
else:
|
||||
if type(payload) != dict:
|
||||
if type(payload) is not dict:
|
||||
raise PreviewTemplateException("Payload must be a valid json object")
|
||||
# Build Alert and AlertGroup objects to pass to templater without saving them to db
|
||||
alert_group_to_template = AlertGroup(channel=channel)
|
||||
|
|
@ -529,7 +529,7 @@ class AlertReceiveChannelView(
|
|||
try:
|
||||
instance.start_maintenance(mode, duration, request.user)
|
||||
except MaintenanceCouldNotBeStartedError as e:
|
||||
if type(instance) == AlertReceiveChannel:
|
||||
if type(instance) is AlertReceiveChannel:
|
||||
detail = {"alert_receive_channel_id": ["Already on maintenance"]}
|
||||
else:
|
||||
detail = str(e)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ def test_multi_type_support(value):
|
|||
LiveSetting.objects.create(name="SOME_NEW_FEATURE_ENABLED", value=value)
|
||||
setting_value = LiveSetting.get_setting("SOME_NEW_FEATURE_ENABLED")
|
||||
|
||||
assert type(setting_value) == type(value)
|
||||
assert type(setting_value) is type(value)
|
||||
assert setting_value == value
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ def test_export_calendar(make_organization_and_user_with_token, make_user_for_or
|
|||
|
||||
cal = Calendar.from_ical(response.data)
|
||||
|
||||
assert type(cal) == Calendar
|
||||
assert type(cal) is Calendar
|
||||
# check there are events
|
||||
assert len(cal.subcomponents) > 0
|
||||
for component in cal.walk():
|
||||
|
|
@ -112,7 +112,7 @@ def test_export_user_calendar(make_organization_and_user_with_token, make_schedu
|
|||
|
||||
cal = Calendar.from_ical(response.data)
|
||||
|
||||
assert type(cal) == Calendar
|
||||
assert type(cal) is Calendar
|
||||
assert cal.get("x-wr-calname") == "On-Call Schedule for {0}".format(user.username)
|
||||
assert cal.get("x-wr-timezone") == "UTC"
|
||||
assert cal.get("calscale") == "GREGORIAN"
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ def list_of_oncall_shifts_from_ical(
|
|||
pytz_tz = pytz.timezone("UTC")
|
||||
return (
|
||||
datetime.datetime.combine(e["start"], datetime.datetime.min.time(), tzinfo=pytz_tz)
|
||||
if type(e["start"]) == datetime.date
|
||||
if type(e["start"]) is datetime.date
|
||||
else e["start"]
|
||||
)
|
||||
|
||||
|
|
@ -234,7 +234,7 @@ def get_shifts_dict(
|
|||
)
|
||||
# Define on-call shift out of ical event that has the actual user
|
||||
if len(users) > 0 or with_empty_shifts:
|
||||
if type(event[ICAL_DATETIME_START].dt) == datetime.date:
|
||||
if type(event[ICAL_DATETIME_START].dt) is datetime.date:
|
||||
start = event[ICAL_DATETIME_START].dt
|
||||
end = event[ICAL_DATETIME_END].dt
|
||||
result_date.append(
|
||||
|
|
@ -642,7 +642,7 @@ def is_icals_equal(first, second):
|
|||
def ical_date_to_datetime(date, tz, start):
|
||||
datetime_to_combine = datetime.time.min
|
||||
all_day = False
|
||||
if type(date) == datetime.date:
|
||||
if type(date) is datetime.date:
|
||||
all_day = True
|
||||
calendar_timezone_offset = datetime.datetime.now().astimezone(tz).utcoffset()
|
||||
date = datetime.datetime.combine(date, datetime_to_combine).astimezone(tz) - calendar_timezone_offset
|
||||
|
|
@ -795,7 +795,7 @@ def start_end_with_respect_to_all_day(event: IcalEvent, calendar_tz):
|
|||
|
||||
def event_start_end_all_day_with_respect_to_type(event: IcalEvent, calendar_tz):
|
||||
all_day = False
|
||||
if type(event[ICAL_DATETIME_START].dt) == datetime.date:
|
||||
if type(event[ICAL_DATETIME_START].dt) is datetime.date:
|
||||
start, end = start_end_with_respect_to_all_day(event, calendar_tz)
|
||||
all_day = True
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ class OnCallSchedule(PolymorphicModel):
|
|||
events: ScheduleEvents = []
|
||||
for shift in shifts:
|
||||
start = shift["start"]
|
||||
all_day = type(start) == datetime.date
|
||||
all_day = type(start) is datetime.date
|
||||
# fix confusing end date for all-day event
|
||||
end = shift["end"] - datetime.timedelta(days=1) if all_day else shift["end"]
|
||||
if all_day and all_day_datetime:
|
||||
|
|
@ -513,7 +513,7 @@ class OnCallSchedule(PolymorphicModel):
|
|||
# check if event was ended or cancelled, update ical
|
||||
dtend = component.get(ICAL_DATETIME_END)
|
||||
dtend_datetime = dtend.dt if dtend else None
|
||||
if dtend_datetime and type(dtend_datetime) == datetime.date:
|
||||
if dtend_datetime and type(dtend_datetime) is datetime.date:
|
||||
# shift or overrides coming from ical calendars can be all day events, change to datetime
|
||||
dtend_datetime = datetime.datetime.combine(
|
||||
dtend.dt, datetime.datetime.min.time(), tzinfo=pytz.UTC
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ class AlertGroupLogSlackRenderer:
|
|||
# get rendered logs
|
||||
result = ""
|
||||
for log_record in all_log_records: # list of AlertGroupLogRecord and UserNotificationPolicyLogRecord logs
|
||||
if type(log_record) == AlertGroupLogRecord:
|
||||
if type(log_record) is AlertGroupLogRecord:
|
||||
result += f"{log_record.rendered_incident_log_line(for_slack=True)}\n"
|
||||
elif type(log_record) == UserNotificationPolicyLogRecord:
|
||||
elif type(log_record) is UserNotificationPolicyLogRecord:
|
||||
result += f"{log_record.rendered_notification_log_line(for_slack=True)}\n"
|
||||
|
||||
attachments.append(
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ def isoformat_with_tz_suffix(value):
|
|||
|
||||
|
||||
def is_string_with_visible_characters(string):
|
||||
return type(string) == str and not string.isspace() and not string == ""
|
||||
return type(string) is str and not string.isspace() and not string == ""
|
||||
|
||||
|
||||
def str_or_backup(string, backup):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue