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 16, 2024
1 parent 54316c8 commit e87020b
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 19 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
3 changes: 1 addition & 2 deletions src/firefighter/slack/views/modals/base_modal/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ def build_modal_with_context(self, body: dict[str, Any], **kwargs: Any) -> View:
if "incident" in self.builder_fn_args and kwargs.get("incident") is None:
if kwargs.get("callback_id") is None:
kwargs["callback_id"] = self.callback_id
if "body" in kwargs:
del kwargs["body"]
kwargs.pop("body", None)
return modal_select.build_modal_fn(**kwargs, select_class=self)

return self.build_modal_fn(**kwargs) # type: ignore
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

0 comments on commit e87020b

Please sign in to comment.