Skip to content

Commit

Permalink
chore(deps): Update Python dependencies with PDM (#22)
Browse files Browse the repository at this point in the history
* chore(deps): Update pdm.lock

Signed-off-by: GitHub <[email protected]>

* chore: update ruff, black

---------

Signed-off-by: GitHub <[email protected]>
Co-authored-by: GabDug <[email protected]>
Co-authored-by: Gabriel Dugny <[email protected]>
  • Loading branch information
3 people authored Jan 30, 2024
1 parent eb3e705 commit bcfd393
Show file tree
Hide file tree
Showing 24 changed files with 280 additions and 253 deletions.
6 changes: 1 addition & 5 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
load_pdm() {
if [[ -d .venv ]] && [[ -d __pypackages__ ]]; then
echo -e "\033[0;31m.envrc: Both .venv and __pypackages__ detected, please remove one of them.\033[0m"
fi

if [[ -d .venv ]]; then
echo ".envrc: Detected .venv, activating it"
local VENV=".venv"
Expand All @@ -11,7 +7,7 @@ load_pdm() {
return
fi

# If no .venv or __pypackages__ exists, try to activate any virtualenv
# If no .venv exists, try to activate any virtualenv
echo ".envrc: No .venv detected, trying to activate any virtualenv"
local VENV=$(dirname $(pdm info --python ))
export VIRTUAL_ENV=$(echo "$VENV" | rev | cut -d'/' -f2- | rev)
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ 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.1.13'
rev: 'v0.1.15'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.12.1
rev: 24.1.1
hooks:
- id: black
- repo: https://github.com/adrienverge/yamllint
Expand Down
264 changes: 132 additions & 132 deletions pdm.lock

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ classifiers = [
dynamic = ["version"]

[project.urls]
Source = "https://github.com/ManoManoTech/firefighter-incident"
Repository = "https://github.com/ManoManoTech/firefighter-incident"
Documentation = "https://manomanotech.github.io/firefighter-incident/latest/"
Changelog = "https://github.com/ManoManoTech/firefighter-incident/releases"

[project.scripts]
ff-web = "main:main"
Expand Down Expand Up @@ -413,7 +415,7 @@ django_settings_module = "firefighter.firefighter.settings"
[tool.pytest.ini_options]
testpaths = ["tests"]
# markers = [{unit="tests that are isolated from the db, external api calls and other mockable internal code."}]
norecursedirs = "*.egg .eggs dist build docs .tox .git __pycache__ node_modules .venv __pypackages__"
norecursedirs = "*.egg .eggs dist build docs .tox .git __pycache__ node_modules .venv"
timeout = 15
# Ignore deprecation warnings from libs
filterwarnings = [
Expand Down Expand Up @@ -535,7 +537,7 @@ external = [
"__init__.py" = ["F401"]
"_version.py" = ["Q000", "UP", "I"]
"**/settings_builder.py" = ["F403"]
"tests/*" = ["S101", "D", "ANN", "PLR2004", "INP", "DTZ005", "TCH", "SLF001"]
"tests/*" = ["S101", "D", "ANN", "PLR2004", "INP", "DTZ005", "TCH", "SLF001", "PLC2701"]
"**/migrations/*" = ["PLR", "D", "ANN", "ARG", "N806", "I002"]
"stubs/*" = ["ARG", "ANN", "D", "INP", "TCH"]
"**/apps.py" = ["F401", "PLC0415"]
Expand Down
6 changes: 3 additions & 3 deletions src/firefighter/firefighter/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import httpx
from django.conf import settings

FF_HTTP_CLIENT_ADDITIONAL_HEADERS: dict[
str, Any
] | None = settings.FF_HTTP_CLIENT_ADDITIONAL_HEADERS
FF_HTTP_CLIENT_ADDITIONAL_HEADERS: dict[str, Any] | None = (
settings.FF_HTTP_CLIENT_ADDITIONAL_HEADERS
)


class HttpClient:
Expand Down
1 change: 1 addition & 0 deletions src/firefighter/firefighter/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
```
"""

# ruff: noqa: E402, F403
# pylint: disable=wrong-import-position
# isort: off
Expand Down
1 change: 1 addition & 0 deletions src/firefighter/firefighter/settings/environments/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This file is required and if `ENV=dev` these values are not used.
"""

from __future__ import annotations

from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions src/firefighter/firefighter/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
1. Import the include() function: `from django.urls import include, path`
2. Add a URL to urlpatterns: `path('blog/', include('blog.urls'))`
"""

from __future__ import annotations

import sys
Expand Down
1 change: 1 addition & 0 deletions src/firefighter/firefighter/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
"""

from __future__ import annotations

# We need to be able to shadow virtualenv things with our own code
Expand Down
6 changes: 3 additions & 3 deletions src/firefighter/incidents/models/incident.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,9 @@ def build_invite_list(self) -> list[User]:
users_list: list[User] = []

# Send signal to modules (Confluence, PagerDuty...)
result_users: list[
tuple[Any, Exception | list[User]]
] = signals.get_invites.send_robust(sender=None, incident=self)
result_users: list[tuple[Any, Exception | list[User]]] = (
signals.get_invites.send_robust(sender=None, incident=self)
)

# Aggregate the results
for provider in result_users:
Expand Down
7 changes: 3 additions & 4 deletions src/firefighter/incidents/views/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
https://github.com/django/django/blob/0dd29209091280ccf34e07c9468746c396b7778e/django/views/defaults.py.
"""


from __future__ import annotations

import logging
Expand Down Expand Up @@ -43,9 +42,9 @@ class JsonHttpResponseBadRequest(JsonResponse, HttpResponseBadRequest):
pass


ERROR_404_TEMPLATE_NAME = (
ERROR_403_TEMPLATE_NAME
) = ERROR_400_TEMPLATE_NAME = ERROR_500_TEMPLATE_NAME = "incidents/errors/base.html"
ERROR_404_TEMPLATE_NAME = ERROR_403_TEMPLATE_NAME = ERROR_400_TEMPLATE_NAME = (
ERROR_500_TEMPLATE_NAME
) = "incidents/errors/base.html"

BACKUP_ERROR_PAGE_TEMPLATE = """
<!doctype html>
Expand Down
1 change: 1 addition & 0 deletions src/firefighter/pagerduty/tasks/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""PagerDuty Celery tasks."""

from __future__ import annotations

from firefighter.pagerduty.tasks.fetch_oncall import fetch_oncalls
Expand Down
22 changes: 12 additions & 10 deletions src/firefighter/slack/messages/slack_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ def get_metadata(self) -> Metadata:
event_payload={
"ff_type": self.id,
"incident_id": self.incident.id,
"incident_update_id": str(self.incident_update.id)
if self.incident_update
else None,
"incident_update_id": (
str(self.incident_update.id) if self.incident_update else None
),
"new_roles": {
role.role_type.slug: user_slack_handle_or_name(
role.user if hasattr(role, "user") else None
Expand Down Expand Up @@ -491,13 +491,15 @@ def get_blocks(self) -> list[Block]:
SectionBlock(
block_id="message_status_update",
fields=fields,
accessory=ButtonElement(
text="Update",
value=str(self.incident.id),
action_id=UpdateStatusModal.open_action,
)
if self.in_channel
else None,
accessory=(
ButtonElement(
text="Update",
value=str(self.incident.id),
action_id=UpdateStatusModal.open_action,
)
if self.in_channel
else None
),
),
]
)
Expand Down
1 change: 1 addition & 0 deletions src/firefighter/slack/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module may be removed in a future version.
"""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
XXX It might be divided into two signals/tasks, one for creating, one for inviting.
XXX Sending the end signal should be done by this signal's caller, not by this signal receiver directly.
"""

from __future__ import annotations

import logging
Expand Down
31 changes: 16 additions & 15 deletions src/firefighter/slack/views/events/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def update_home_tab(
event: dict[str, Any], client: WebClient = DefaultWebClient
) -> None:
logger.debug(event)

# Show only the latest 30 incidents, as Slack does not allow more than 100 elements
shown_incidents = list(
Incident.objects.filter(_status__lt=IncidentStatus.CLOSED.value)
Expand Down Expand Up @@ -154,20 +153,22 @@ def _home_incident_element(
text=f":speaking_head_in_silhouette: *Last update:* {date_time(incident.updated_at) }"
),
],
accessory=OverflowMenuElement(
action_id="app_home_incident_action",
options=[
Option(text="Update status", value="update_status"),
Option(
text="See status page",
url=incident.status_page_url
+ "?utm_medium=FireFighter+Slack&utm_source=Slack+Home&utm_campaign=Slack+Home+Button",
value="open_link",
),
],
)
if show_actions
else None,
accessory=(
OverflowMenuElement(
action_id="app_home_incident_action",
options=[
Option(text="Update status", value="update_status"),
Option(
text="See status page",
url=incident.status_page_url
+ "?utm_medium=FireFighter+Slack&utm_source=Slack+Home&utm_campaign=Slack+Home+Button",
value="open_link",
),
],
)
if show_actions
else None
),
),
slack_block_quote(incident.description, length=1500),
]
Expand Down
26 changes: 14 additions & 12 deletions src/firefighter/slack/views/modals/close.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,20 @@ def build_modal_fn(
),
ActionsBlock(
elements=[
ButtonElement(
text="Fill the post-mortem on Confluence",
action_id="open_link",
url=incident.postmortem_for.page_edit_url,
style="primary",
)
if hasattr(incident, "postmortem_for")
else ButtonElement(
text="Create the post-mortem",
action_id=str(PostMortemModal.push_action),
value=str(incident.id),
style="primary",
(
ButtonElement(
text="Fill the post-mortem on Confluence",
action_id="open_link",
url=incident.postmortem_for.page_edit_url,
style="primary",
)
if hasattr(incident, "postmortem_for")
else ButtonElement(
text="Create the post-mortem",
action_id=str(PostMortemModal.push_action),
value=str(incident.id),
style="primary",
)
),
ButtonElement(
text="Update status",
Expand Down
18 changes: 9 additions & 9 deletions src/firefighter/slack/views/modals/key_event_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ def handle_modal_fn( # type: ignore[override]
"""Handle the time and date inputs for the key events."""
logger.debug(body)

slack_form: SlackForm[
IncidentUpdateKeyEventsForm
] | None = self.handle_form_errors(
ack,
body,
forms_kwargs={
"incident": incident,
"user": user,
},
slack_form: SlackForm[IncidentUpdateKeyEventsForm] | None = (
self.handle_form_errors(
ack,
body,
forms_kwargs={
"incident": incident,
"user": user,
},
)
)
form = slack_form.form if slack_form else None

Expand Down
18 changes: 9 additions & 9 deletions src/firefighter/slack/views/modals/open.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def build_modal_fn(self, open_incident_context: OpeningData | None = None, user:
):
open_incident_context["details_form_data"] = {}
assert open_incident_context["details_form_data"] is not None # noqa: S101
open_incident_context["details_form_data"][
"priority"
] = open_incident_context["priority"]
open_incident_context["details_form_data"]["priority"] = (
open_incident_context["priority"]
)

# Make blocks with all this context
intro_blocks = self.get_intro_blocks()
Expand Down Expand Up @@ -353,9 +353,9 @@ def _validate_details_form(
if not details_form_modal_class:
return False, None, None

details_form_class: type[
CreateIncidentFormBase
] = details_form_modal_class.form_class
details_form_class: type[CreateIncidentFormBase] = (
details_form_modal_class.form_class
)

if not details_form_class:
return False, None, None
Expand Down Expand Up @@ -482,9 +482,9 @@ def handle_modal_fn( # type: ignore
data, incident_type_value
)
if details_form_modal_class:
details_form_class: type[
CreateIncidentFormBase
] = details_form_modal_class.form_class
details_form_class: type[CreateIncidentFormBase] = (
details_form_modal_class.form_class
)
if details_form_class:
details_form: CreateIncidentFormBase = details_form_class(
details_form_data_raw
Expand Down
12 changes: 7 additions & 5 deletions src/firefighter/slack/views/modals/opening/details/critical.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ class CreateIncidentFormSlack(CreateIncidentForm):
"placeholder": "Select a priority",
},
"widget": {
"post_block": SectionBlock(
text=f"_<{settings.SLACK_SEVERITY_HELP_GUIDE_URL}|How to choose the priority?>_"
)
if settings.SLACK_SEVERITY_HELP_GUIDE_URL
else None,
"post_block": (
SectionBlock(
text=f"_<{settings.SLACK_SEVERITY_HELP_GUIDE_URL}|How to choose the priority?>_"
)
if settings.SLACK_SEVERITY_HELP_GUIDE_URL
else None
),
"label_from_instance": lambda obj: f"{obj.emoji} {obj.name} - {obj.description}",
},
},
Expand Down
Loading

0 comments on commit bcfd393

Please sign in to comment.