Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 9, 2024
1 parent 7b0a166 commit 98095c6
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions scripts/gen_credits.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ def _get_license(pkg_name: str) -> str:
data = metadata(pkg_name)
except PackageNotFoundError:
return "?"
license_name = cast(dict, data).get("License", "").strip()
license_name = cast("dict", data).get("License", "").strip()
multiple_lines = bool(license_name.count("\n"))
# TODO: Remove author logic once all my packages licenses are fixed.
author = ""
if multiple_lines or not license_name or license_name == "UNKNOWN":
for header, value in cast(dict, data).items():
for header, value in cast("dict", data).items():
if header == "Classifier" and value.startswith("License ::"):
license_name = value.rsplit("::", 1)[1].strip()
elif header == "Author-email":
Expand Down
2 changes: 1 addition & 1 deletion src/firefighter/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class APITokenProxy(APIToken):

@property
def pk(self: Self) -> uuid.UUID:
return cast(uuid.UUID, self.user_id) # pyright: ignore[reportGeneralTypeIssues]
return cast("uuid.UUID", self.user_id) # pyright: ignore[reportGeneralTypeIssues]

class Meta(TypedModelMeta):
permissions = [
Expand Down
2 changes: 1 addition & 1 deletion src/firefighter/confluence/tasks/sync_postmortems.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def sync_postmortems() -> None:
if not Incident.objects.filter(id=incident_id).exists():
pm_missing_incident.append(data["name"])
continue
data_editable = cast(dict[str, str], data)
data_editable = cast("dict[str, str]", data)
try:
PostMortem.objects.update_or_create(
page_id=int(data_editable.pop("page_id")),
Expand Down
2 changes: 1 addition & 1 deletion src/firefighter/confluence/tasks/sync_runbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def sync_runbooks() -> None:
all_fetched_ids.add(page_id)
data["name"] = data["name"].removesuffix("[RUNBOOK]").strip()

data_editable = cast(dict[str, str], data)
data_editable = cast("dict[str, str]", data)
data_editable["title"] = (
data_editable["name"].removesuffix("[RUNBOOK]").strip()
)
Expand Down
2 changes: 1 addition & 1 deletion src/firefighter/firefighter/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
if TYPE_CHECKING:
from collections.abc import Callable

register_global: template.Library = cast(template.Library, register_base)
register_global: template.Library = cast("template.Library", register_base)
V = TypeVar("V")


Expand Down
6 changes: 3 additions & 3 deletions src/firefighter/jira_app/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def _get_project_config_workflow_base(
# XXX Try catch
# XXX Override Jira Class / split client and service
return cast(
dict[str, Any],
"dict[str, Any]",
self.jira._session.get( # noqa: SLF001
url,
headers=self.jira._options["headers"], # noqa: SLF001
Expand Down Expand Up @@ -372,8 +372,8 @@ def _get_project_config_workflow_from_builder_base(
del status["y"]

return WorkflowBuilderResponse(
statuses=cast(list[Status], statuses),
transitions=cast(list[Transition], transitions),
statuses=cast("list[Status]", statuses),
transitions=cast("list[Transition]", transitions),
)

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion src/firefighter/logging/custom_json_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
DD_TRACE_ENABLED = os.environ.get("DD_TRACE_ENABLED")
if DD_TRACE_ENABLED:
from ddtrace import tracer
GUNICORN_KEY_RE = re.compile("{([^}]+)}")
GUNICORN_KEY_RE = re.compile(r"{([^}]+)}")


def del_if_possible(obj: dict[str, Any], key: str) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/firefighter/raid/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def _get_project_config_workflow_from_builder(self) -> WorkflowBuilderResponse:
@staticmethod
def _jira_object(issue: dict[str, Any]) -> JiraObject:
if issue_id := issue.get("id"):
jira_id = int(cast(str, issue_id))
jira_id = int(cast("str", issue_id))
else:
raise TypeError("Jira ID not found")

Expand Down
4 changes: 2 additions & 2 deletions src/firefighter/slack/models/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def _pin_message(
def add_bookmark(
self,
title: str,
_type: str = "link",
type_: str = "link",
emoji: str | None = None,
entity_id: str | None = None,
link: str | None = None, # include when type is 'link'
Expand All @@ -415,7 +415,7 @@ def add_bookmark(
title=title,
link=link,
emoji=emoji,
type=_type,
type=type_,
entity_id=entity_id,
parent_id=parent_id,
**kwargs,
Expand Down
4 changes: 2 additions & 2 deletions src/firefighter/slack/views/modals/open.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def _build_response_type_blocks(open_incident_context: OpeningData) -> list[Bloc
return []

response_types: list[ResponseType] = cast(
list[ResponseType], INCIDENT_TYPES.keys()
"list[ResponseType]", INCIDENT_TYPES.keys()
)
elements: list[ButtonElement] = []

Expand Down Expand Up @@ -512,7 +512,7 @@ def handle_set_incident_response_type_action(
action_name: str = body.get("actions", [{}])[0].get("action_id", "")
action_name = action_name.replace("incident_open_set_res_type_", "")
opening_data = cast(
OpeningData, json.loads(body.get("actions", [{}])[0].get("value", {})) or {}
"OpeningData", json.loads(body.get("actions", [{}])[0].get("value", {})) or {}
)

OpenModal._update_incident_modal(
Expand Down
6 changes: 3 additions & 3 deletions src/firefighter/slack/views/modals/opening/select_impact.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def _handle_action_push(
) -> None:
body = request.body
data = cast(
OpeningData, json.loads(body.get("actions", [{}])[0].get("value", {})) or {}
"OpeningData", json.loads(body.get("actions", [{}])[0].get("value", {})) or {}
)
view = self.build_modal_fn(body, open_incident_context=data)
request.context.ack()
Expand Down Expand Up @@ -192,7 +192,7 @@ def _update_private_metadata(
and not isinstance(form.form.data[field_name], Model)
and field.queryset is not None
):
queryset = cast(QuerySet[ImpactLevel], field.queryset)
queryset = cast("QuerySet[ImpactLevel]", field.queryset)
try:
form.form.data[field_name] = queryset.get( # type: ignore
pk=form.form.data[field_name]
Expand All @@ -206,7 +206,7 @@ def _update_private_metadata(
response_type=SelectImpactModal._calculate_proposed_incident_type(
form.form.suggest_priority_from_impact()
),
impact_form_data=cast(dict[str, Any], form.form.data),
impact_form_data=cast("dict[str, Any]", form.form.data),
details_form_data=private_metadata_raw.get("details_form_data", {}),
incident_type=private_metadata_raw.get("incident_type"),
)
Expand Down
2 changes: 1 addition & 1 deletion src/firefighter/slack/views/modals/opening/set_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def handle_modal_fn( # type: ignore
pk=private_metadata["priority"]
)
data = OpeningData(
details_form_data=cast(dict[str, Any], form.data),
details_form_data=cast("dict[str, Any]", form.data),
impact_form_data=private_metadata.get("impact_form_data"),
incident_type=private_metadata.get("incident_type"),
response_type=private_metadata.get("response_type"),
Expand Down
8 changes: 4 additions & 4 deletions tests/test_raid/test_raid_client_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def test_get_jira_user_from_user(
Mock(raw={"accountId": "123", "emailAddress": "[email protected]"})
]
)
_search_users = mocker.patch.object(raid_client.jira, "search_users")
_search_users.return_value = [
search_users = mocker.patch.object(raid_client.jira, "search_users")
search_users.return_value = [
Mock(raw={"accountId": "123", "emailAddress": "[email protected]"})
]
# Test when the user is valid and exists in Jira
Expand All @@ -87,13 +87,13 @@ def test_get_jira_user_from_user_in_db(
# Test when the user is valid and exists in Jira
user.jira_user = JiraUser.objects.create(id="123", user=user)
# Prepare no call jira.search_users(query=email_query)
_search_users = mocker.patch.object(raid_client.jira, "search_users")
search_users = mocker.patch.object(raid_client.jira, "search_users")

jira_user = raid_client.get_jira_user_from_user(user)
assert jira_user.user.email == "[email protected]"

# Assert no call jira.search_users(query=email_query)
_search_users.assert_not_called()
search_users.assert_not_called()


@pytest.mark.django_db
Expand Down
8 changes: 4 additions & 4 deletions tests/test_slack/views/modals/test_close.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_submit_valid_form_open_incident(
incident.status = IncidentStatus.OPEN

modal = CloseModal()
_trigger_incident_workflow = mocker.patch.object(
trigger_incident_workflow = mocker.patch.object(
modal, "_trigger_incident_workflow"
)
respond = mocker.patch(
Expand All @@ -122,7 +122,7 @@ def test_submit_valid_form_open_incident(

# Assert
ack.assert_called_once_with()
_trigger_incident_workflow.assert_not_called()
trigger_incident_workflow.assert_not_called()
respond.assert_called_once()

@staticmethod
Expand All @@ -136,7 +136,7 @@ def test_submit_valid_form_closable_incident(
new_callable=mocker.PropertyMock,
)
incident.status = IncidentStatus.POST_MORTEM
_trigger_incident_workflow = mocker.patch.object(
trigger_incident_workflow = mocker.patch.object(
modal, "_trigger_incident_workflow"
)

Expand All @@ -150,7 +150,7 @@ def test_submit_valid_form_closable_incident(

# Assert
ack.assert_called_once_with()
_trigger_incident_workflow.assert_called_once()
trigger_incident_workflow.assert_called_once()


valid_submission = {
Expand Down
4 changes: 2 additions & 2 deletions tests/test_slack/views/modals/test_update_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_submit_empty_bodied_form(incident: Incident) -> None:
@staticmethod
def test_submit_valid_form(mocker: MockerFixture, incident: Incident) -> None:
modal = UpdateStatusModal()
_trigger_incident_workflow = mocker.patch.object(
trigger_incident_workflow = mocker.patch.object(
modal, "_trigger_incident_workflow"
)

Expand All @@ -62,7 +62,7 @@ def test_submit_valid_form(mocker: MockerFixture, incident: Incident) -> None:

# Assert
ack.assert_called_once_with()
_trigger_incident_workflow.assert_called_once()
trigger_incident_workflow.assert_called_once()


valid_submission = {
Expand Down

0 comments on commit 98095c6

Please sign in to comment.