Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #108

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ default_language_version:
python: python3.12
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-toml
- id: trailing-whitespace
Expand All @@ -19,7 +19,7 @@ repos:
- id: fix-byte-order-marker
# Versions must be kept in sync with lockfile
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.6.8'
rev: 'v0.9.4'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -30,14 +30,14 @@ repos:
- id: yamllint

- repo: https://github.com/rtts/djhtml
rev: '3.0.6'
rev: '3.0.7'
hooks:
- id: djhtml
- id: djcss
- id: djjs

- repo: https://github.com/adamchainz/djade-pre-commit
rev: "1.1.1"
rev: "1.3.2"
hooks:
- id: djade
args: [--target-version, "4.2"]
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
@@ -1,6 +1,6 @@
from __future__ import annotations

import uuid

Check failure on line 3 in src/firefighter/api/models.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.11, ubuntu-latest)

Ruff (TCH003)

src/firefighter/api/models.py:3:8: TCH003 Move standard library import `uuid` into a type-checking block
from typing import TYPE_CHECKING, ClassVar, Self, cast

from django.conf import settings
Expand All @@ -26,7 +26,7 @@

@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 @@ -7,13 +7,13 @@

import markdown as md
import nh3
from django import template

Check failure on line 10 in src/firefighter/firefighter/filters.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.11, ubuntu-latest)

Ruff (TCH002)

src/firefighter/firefighter/filters.py:10:20: TCH002 Move third-party import `django.template` into a type-checking block
from django.template.defaulttags import register as register_base

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 @@ -16,7 +16,7 @@

from firefighter.firefighter.utils import get_in
from firefighter.incidents.forms.select_impact import SelectImpactForm
from firefighter.incidents.models.impact import ImpactLevel

Check failure on line 19 in src/firefighter/slack/views/modals/opening/select_impact.py

View workflow job for this annotation

GitHub Actions / Test and build Python (3.11, ubuntu-latest)

Ruff (TCH001)

src/firefighter/slack/views/modals/opening/select_impact.py:19:49: TCH001 Move application import `firefighter.incidents.models.impact.ImpactLevel` into a type-checking block
from firefighter.incidents.models.priority import Priority
from firefighter.slack.slack_app import SlackApp
from firefighter.slack.views.modals import modal_open
Expand Down Expand Up @@ -146,7 +146,7 @@
) -> 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 @@
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 @@
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
Loading