diff --git a/scripts/gen_credits.py b/scripts/gen_credits.py index cb69b0db..1831e67f 100644 --- a/scripts/gen_credits.py +++ b/scripts/gen_credits.py @@ -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": diff --git a/src/firefighter/api/models.py b/src/firefighter/api/models.py index 1d8255df..4b005f16 100644 --- a/src/firefighter/api/models.py +++ b/src/firefighter/api/models.py @@ -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 = [ diff --git a/src/firefighter/confluence/tasks/sync_postmortems.py b/src/firefighter/confluence/tasks/sync_postmortems.py index a906ea19..899c7b8a 100644 --- a/src/firefighter/confluence/tasks/sync_postmortems.py +++ b/src/firefighter/confluence/tasks/sync_postmortems.py @@ -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")), diff --git a/src/firefighter/confluence/tasks/sync_runbooks.py b/src/firefighter/confluence/tasks/sync_runbooks.py index 1b453ded..393455d2 100644 --- a/src/firefighter/confluence/tasks/sync_runbooks.py +++ b/src/firefighter/confluence/tasks/sync_runbooks.py @@ -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() ) diff --git a/src/firefighter/firefighter/filters.py b/src/firefighter/firefighter/filters.py index f923c72f..0dcdf139 100644 --- a/src/firefighter/firefighter/filters.py +++ b/src/firefighter/firefighter/filters.py @@ -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") diff --git a/src/firefighter/jira_app/client.py b/src/firefighter/jira_app/client.py index 58e9f94c..855cb918 100644 --- a/src/firefighter/jira_app/client.py +++ b/src/firefighter/jira_app/client.py @@ -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 @@ -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 diff --git a/src/firefighter/logging/custom_json_formatter.py b/src/firefighter/logging/custom_json_formatter.py index 3b885ca2..5c895258 100644 --- a/src/firefighter/logging/custom_json_formatter.py +++ b/src/firefighter/logging/custom_json_formatter.py @@ -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: diff --git a/src/firefighter/raid/client.py b/src/firefighter/raid/client.py index 486dacb8..5f371131 100644 --- a/src/firefighter/raid/client.py +++ b/src/firefighter/raid/client.py @@ -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") diff --git a/src/firefighter/slack/views/modals/base_modal/mixins.py b/src/firefighter/slack/views/modals/base_modal/mixins.py index 450d585f..fc7ff8c7 100644 --- a/src/firefighter/slack/views/modals/base_modal/mixins.py +++ b/src/firefighter/slack/views/modals/base_modal/mixins.py @@ -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 diff --git a/src/firefighter/slack/views/modals/open.py b/src/firefighter/slack/views/modals/open.py index 4c9134e5..ecb1eb49 100644 --- a/src/firefighter/slack/views/modals/open.py +++ b/src/firefighter/slack/views/modals/open.py @@ -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] = [] @@ -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( diff --git a/src/firefighter/slack/views/modals/opening/select_impact.py b/src/firefighter/slack/views/modals/opening/select_impact.py index b973d512..00d6df53 100644 --- a/src/firefighter/slack/views/modals/opening/select_impact.py +++ b/src/firefighter/slack/views/modals/opening/select_impact.py @@ -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() @@ -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] @@ -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"), ) diff --git a/src/firefighter/slack/views/modals/opening/set_details.py b/src/firefighter/slack/views/modals/opening/set_details.py index 415a9c88..097bd51b 100644 --- a/src/firefighter/slack/views/modals/opening/set_details.py +++ b/src/firefighter/slack/views/modals/opening/set_details.py @@ -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"),