Skip to content

Commit 14b758a

Browse files
authored
Updates pre-commit hooks versions and fixes typos and formatting (Netflix#5277)
1 parent a3bae3a commit 14b758a

File tree

124 files changed

+265
-243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+265
-243
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ yarn.lock
176176

177177
# End of https://www.gitignore.io/api/macos,visualstudiocode,python
178178

179-
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
179+
# Custom rules (everything added below won't be overridden by 'Generate .gitignore File' if you use 'Update' option)
180180

181181
### Vim ###
182182
# Swap

.pre-commit-config.yaml

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ default_language_version:
1414

1515
repos:
1616
- repo: https://github.com/astral-sh/ruff-pre-commit
17-
# Ruff version.
18-
rev: v0.1.4
17+
# ruff version.
18+
rev: v0.6.4
1919
hooks:
2020
# Run the linter.
2121
#
@@ -28,9 +28,10 @@ repos:
2828

2929
# Typos
3030
- repo: https://github.com/crate-ci/typos
31-
rev: v1.16.23
31+
rev: v1.24.5
3232
hooks:
3333
- id: typos
34+
exclude: ^(data/dispatch-sample-data.dump|src/dispatch/static/dispatch/src/|src/dispatch/database/revisions/)
3435

3536
# Pytest
3637
- repo: local

docker/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ COPY --from=sdist /dist/*.whl /tmp/dist/
9393
RUN buildDeps="" \
9494
&& apt-get update \
9595
&& apt-get install -y --no-install-recommends "$buildDeps" \
96-
# remove internal index when internal plugins are seperated
96+
# remove internal index when internal plugins are separated
9797
&& pip install -U /tmp/dist/*.whl \
9898
&& apt-get purge -y --auto-remove "$buildDeps" \
9999
# We install run-time dependencies strictly after

docs/docs/administration/contributing/core.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### Folder Structure
66

7-
Dispatch's backend is a typical python web app. Its folder structure is a simple one and is mirrored between the backend code \(python\) and the frontend code \(javscript\).
7+
Dispatch's backend is a typical python web app. Its folder structure is a simple one and is mirrored between the backend code \(python\) and the frontend code \(javascript\).
88

99
```text
1010
├── dispatch

docs/docs/administration/settings/case/case-type.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Dispatch allows you to categorize your cases by defining case types and to map t
1616

1717
**Case Template:** Allows you to create a new or map an existing case document template to the case type.
1818

19-
**Oncall Service:** Allows you to map an existing oncall service that will be used to determing the owner of the case.
19+
**Oncall Service:** Allows you to map an existing oncall service that will be used to determining the owner of the case.
2020

2121
**Incident Type:** The type of incident that will be created and linked to the case if a case of this type is moved to the Escalated status.
2222

docs/docs/administration/settings/cost_model.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ If an incident type does not have a specific cost model assigned, the default cl
1313
## Key Features
1414

1515
### Customizable Cost Models
16-
Users have the flexibility to define their unique cost models based on their organization's workflow and tools. This customization can be tailored to each incident type, providing a versitile approach to cost calculation. The cost model for an incident type can be changed at any time. When cost model changes are made to the incident type or an incident changes its type, all participant activity costs moving forward will be calculated using the new cost model.
16+
Users have the flexibility to define their unique cost models based on their organization's workflow and tools. This customization can be tailored to each incident type, providing a versatile approach to cost calculation. The cost model for an incident type can be changed at any time. When cost model changes are made to the incident type or an incident changes its type, all participant activity costs moving forward will be calculated using the new cost model.
1717

1818
### Plugin-Based Tracking
1919
Users can track costs from their existing tools by using our plugin-based tracking system. Users have the flexibility to select which plugins and specific plugin events they want to track, offering a targeted approach to cost calculation.

docs/docs/administration/settings/knowledge/runbooks.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Today, there are two types of runbooks although their actual usage is the same.
1313

1414
### Engagement
1515

16-
Runbook documents are dymanically matched to an incident based on their engagement filter. Similar to notification's a user can define for which incidents a document should be recommended to incident participants.
16+
Runbook documents are dynamically matched to an incident based on their engagement filter. Similar to notification's a user can define for which incidents a document should be recommended to incident participants.
1717

1818
On incident creation (or when an important incident variable changes e.g. incident type) Dispatch will send the incident channel a document suggestion notification.
1919

docs/docs/administration/settings/signal/definition.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Signal Definition
22

3-
Signal Defintions are your starting point for onboarding a new Signal into Dispatch and allow a number of different configuration options.
3+
Signal Definitions are your starting point for onboarding a new Signal into Dispatch and allow a number of different configuration options.
44

55
## Sending Signals to Dispatch
66

@@ -59,7 +59,7 @@ don't necessarily warrant triage and investigation on their own. But, you can st
5959

6060
![](/img/admin-ui-signal-definition.png)
6161

62-
**Variant**: The same signal can have multiple varitants with different defintions.
62+
**Variant**: The same signal can have multiple varitants with different definitions.
6363

6464
**Owner**: Typically the team or owner that produces the Siganl.
6565

docs/docs/administration/settings/signal/engagement-filter.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Engagement Filter
22

3-
Engagement Filters are used to automate the process of reaching out to a user invovled in a specific Signal Instance. Engagement Filters make use of Entity Types that match email addresses for users in your environment and custom message you configure to be sent to those users. Engagement Filters also support multi-factor authentication when validating suspicious behavior. This feature is useful when you want to be confident the user you engaged is actually who they say they are and not a malicious actor.
3+
Engagement Filters are used to automate the process of reaching out to a user involved in a specific Signal Instance. Engagement Filters make use of Entity Types that match email addresses for users in your environment and custom message you configure to be sent to those users. Engagement Filters also support multi-factor authentication when validating suspicious behavior. This feature is useful when you want to be confident the user you engaged is actually who they say they are and not a malicious actor.
44

55
### Creating an Engagement Filter
66

docs/docs/administration/user.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Users or organizational members represent users of the Dispatch UI and are diffe
1212

1313
</div>
1414

15-
**Role:** Dispatch uses role-based access control (RBAC) for its UI. Currently, this is only used to protect sensitive incidents whose visibilty is set to restricted. We do not currently have any controls surrounding Dispatch configuration and settings. There are four roles defined by Dispatch:
15+
**Role:** Dispatch uses role-based access control (RBAC) for its UI. Currently, this is only used to protect sensitive incidents whose visibility is set to restricted. We do not currently have any controls surrounding Dispatch configuration and settings. There are four roles defined by Dispatch:
1616

1717
- Member: Can access everything except restricted incidents unless they are a direct participant.
1818
- Admin: Allows full access to the Dispatch UI and all incidents, whether their visibility is open or restricted.

docs/scripts/openapi.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -13044,7 +13044,7 @@ paths:
1304413044
- documents
1304513045
/{organization}/entity:
1304613046
get:
13047-
description: Get all entitys, or only those matching a given search term.
13047+
description: Get all entities, or only those matching a given search term.
1304813048
operationId: get_entities__organization__entity_get
1304913049
parameters:
1305013050
- in: path
@@ -13350,7 +13350,7 @@ paths:
1335013350
tags:
1335113351
- entities
1335213352
put:
13353-
description: Updates an exisiting entity.
13353+
description: Updates an existing entity.
1335413354
operationId: update_entity__organization__entity__entity_id__put
1335513355
parameters:
1335613356
- in: path
@@ -14548,7 +14548,7 @@ paths:
1454814548
tags:
1454914549
- feedback
1455014550
put:
14551-
description: Updates a feeback entry by its id.
14551+
description: Updates a feedback entry by its id.
1455214552
operationId: update_feedback__organization__feedback__feedback_id__put
1455314553
parameters:
1455414554
- in: path
@@ -21315,7 +21315,7 @@ paths:
2131521315
tags:
2131621316
- tags
2131721317
put:
21318-
description: Updates an exisiting tag.
21318+
description: Updates an existing tag.
2131921319
operationId: update_tag__organization__tags__tag_id__put
2132021320
parameters:
2132121321
- in: path

src/dispatch/auth/service.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
:copyright: (c) 2019 by Netflix Inc., see AUTHORS for more
55
:license: Apache, see LICENSE for more details.
66
"""
7+
78
import logging
89
from typing import Annotated, Optional
910

src/dispatch/case/messaging.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
:copyright: (c) 2019 by Netflix Inc., see AUTHORS for more
55
:license: Apache, see LICENSE for more details.
66
"""
7+
78
import logging
89

910
from sqlalchemy.orm import Session
@@ -29,7 +30,9 @@
2930
from dispatch.plugin import service as plugin_service
3031
from dispatch.event import service as event_service
3132
from dispatch.notification import service as notification_service
32-
from dispatch.plugins.dispatch_slack.case.messages import create_welcome_ephemeral_message_to_participant
33+
from dispatch.plugins.dispatch_slack.case.messages import (
34+
create_welcome_ephemeral_message_to_participant,
35+
)
3336

3437
from .enums import CaseStatus
3538

@@ -124,9 +127,7 @@ def send_case_created_notifications(case: Case, db_session: Session):
124127
notification_template.insert(0, CASE_NAME)
125128

126129
case_description = (
127-
case.description
128-
if len(case.description) <= 500
129-
else f"{case.description[:500]}..."
130+
case.description if len(case.description) <= 500 else f"{case.description[:500]}..."
130131
)
131132

132133
notification_kwargs = {
@@ -180,9 +181,7 @@ def send_case_created_notifications(case: Case, db_session: Session):
180181
log.debug("Case created notifications sent.")
181182

182183

183-
def send_case_update_notifications(
184-
case: Case, previous_case: CaseRead, db_session: Session
185-
):
184+
def send_case_update_notifications(case: Case, previous_case: CaseRead, db_session: Session):
186185
"""Sends notifications about case changes."""
187186
notification_text = "Case Notification"
188187
notification_type = MessageType.case_notification
@@ -319,9 +318,7 @@ def send_case_welcome_participant_message(
319318
)
320319

321320
if not plugin:
322-
log.warning(
323-
"Case participant welcome message not sent. No conversation plugin enabled."
324-
)
321+
log.warning("Case participant welcome message not sent. No conversation plugin enabled.")
325322
return
326323

327324
welcome_message = create_welcome_ephemeral_message_to_participant(case=case)

src/dispatch/case_cost/service.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def update_case_response_cost_for_case_type(db_session, case_type: CaseType) ->
112112

113113
def calculate_response_cost(hourly_rate, total_response_time_seconds) -> int:
114114
"""Calculates and rounds up the case response cost."""
115-
return math.ceil(((total_response_time_seconds / SECONDS_IN_HOUR)) * hourly_rate)
115+
return math.ceil((total_response_time_seconds / SECONDS_IN_HOUR) * hourly_rate)
116116

117117

118118
def get_default_case_response_cost(case: Case, db_session: SessionLocal) -> Optional[CaseCost]:
@@ -223,7 +223,6 @@ def calculate_case_response_cost_with_cost_model(case: Case, db_session: Session
223223
if case.case_type.cost_model:
224224
# Get the cost model. Iterate through all the listed activities we want to record.
225225
for activity in case.case_type.cost_model.activities:
226-
227226
# Array of sorted (timestamp, user_id) tuples.
228227
case_events = fetch_case_events(
229228
case=case, activity=activity, oldest=oldest, db_session=db_session

src/dispatch/cli.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,9 @@ def drop_database():
364364
"""Drops all data in database."""
365365
from sqlalchemy_utils import database_exists, drop_database
366366

367-
database_hostname = click.prompt(f"Please enter the database hostname (env = {config.DATABASE_HOSTNAME})")
367+
database_hostname = click.prompt(
368+
f"Please enter the database hostname (env = {config.DATABASE_HOSTNAME})"
369+
)
368370
database_name = click.prompt(f"Please enter the database name (env = {config.DATABASE_NAME})")
369371
sqlalchemy_database_uri = f"postgresql+psycopg2://{config._DATABASE_CREDENTIAL_USER}:{config._QUOTED_DATABASE_PASSWORD}@{database_hostname}:{config.DATABASE_PORT}/{database_name}"
370372

@@ -375,9 +377,7 @@ def drop_database():
375377
drop_database(str(sqlalchemy_database_uri))
376378
click.secho("Success.", fg="green")
377379
else:
378-
click.secho(
379-
f"Database '{database_hostname}:{database_name}' does not exist!!!", fg="red"
380-
)
380+
click.secho(f"Database '{database_hostname}:{database_name}' does not exist!!!", fg="red")
381381

382382

383383
@dispatch_database.command("upgrade")

src/dispatch/common/managers.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
.. moduleauthor:: Kevin Glisson <[email protected]>
88
"""
9+
910
import logging
1011
from dispatch.exceptions import InvalidConfigurationError
1112

src/dispatch/cost_model/service.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def update(*, db_session, cost_model_in: CostModelUpdate) -> CostModel:
112112
cost_model_in.updated_at if cost_model_in.updated_at else datetime.utcnow()
113113
)
114114

115-
# Update all recognized activities. Delete all removed activites.
115+
# Update all recognized activities. Delete all removed activities.
116116
update_activities = []
117117
delete_activities = []
118118

src/dispatch/data/query/service.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def get_by_name_or_raise(*, db_session, query_in: QueryRead, project_id: int) ->
4646

4747

4848
def get_all(*, db_session):
49-
"""Gets all querys."""
49+
"""Gets all queries."""
5050
return db_session.query(Query)
5151

5252

src/dispatch/data/source/models.py

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class QueryReadMinimal(DispatchBase):
101101
name: str
102102
description: str
103103

104+
104105
class Link(DispatchBase):
105106
id: Optional[int]
106107
name: Optional[str]

src/dispatch/data/source/scheduled.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
:copyright: (c) 2022 by Netflix Inc., see AUTHORS for more
55
:license: Apache, see LICENSE for more details.
66
"""
7+
78
import logging
89

910
from schedule import every

src/dispatch/database/service.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,9 @@ def build_filters(filter_spec):
185185

186186
if not _is_iterable_filter(fn_args):
187187
raise BadFilterFormat(
188-
"`{}` value must be an iterable across the function "
189-
"arguments".format(boolean_function.key)
188+
"`{}` value must be an iterable across the function " "arguments".format(
189+
boolean_function.key
190+
)
190191
)
191192
if boolean_function.only_one_arg and len(fn_args) != 1:
192193
raise BadFilterFormat(

src/dispatch/email_templates/service.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ def get(*, email_template_id: int, db_session: Session) -> Optional[EmailTemplat
1818
)
1919

2020

21-
def get_by_type(*, email_template_type: str, project_id: int, db_session: Session) -> Optional[EmailTemplates]:
21+
def get_by_type(
22+
*, email_template_type: str, project_id: int, db_session: Session
23+
) -> Optional[EmailTemplates]:
2224
"""Gets an email template by its type."""
2325
return (
2426
db_session.query(EmailTemplates)
@@ -40,9 +42,7 @@ def create(*, email_template_in: EmailTemplatesCreate, db_session: Session) -> E
4042
db_session=db_session, project_in=email_template_in.project
4143
)
4244

43-
email_template = EmailTemplates(
44-
**email_template_in.dict(exclude={"project"}), project=project
45-
)
45+
email_template = EmailTemplates(**email_template_in.dict(exclude={"project"}), project=project)
4646

4747
db_session.add(email_template)
4848
db_session.commit()

src/dispatch/email_templates/views.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
from dispatch.models import PrimaryKey
1515
from dispatch.exceptions import ExistsError
1616

17-
from .models import EmailTemplatesRead, EmailTemplatesUpdate, EmailTemplatesPagination, EmailTemplatesCreate
17+
from .models import (
18+
EmailTemplatesRead,
19+
EmailTemplatesUpdate,
20+
EmailTemplatesPagination,
21+
EmailTemplatesCreate,
22+
)
1823
from .service import get, create, update, delete
1924

2025
log = logging.getLogger(__name__)
@@ -47,9 +52,7 @@ def create_email_template(
4752
):
4853
"""Create a new email template."""
4954
try:
50-
return create(
51-
db_session=db_session, email_template_in=email_template_in
52-
)
55+
return create(db_session=db_session, email_template_in=email_template_in)
5356
except IntegrityError:
5457
raise ValidationError(
5558
[
@@ -80,7 +83,9 @@ def update_email_template(
8083
)
8184
try:
8285
email_template = update(
83-
db_session=db_session, email_template=email_template, email_template_in=email_template_in
86+
db_session=db_session,
87+
email_template=email_template,
88+
email_template_in=email_template_in,
8489
)
8590
except IntegrityError:
8691
raise ValidationError(

src/dispatch/entity/views.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
@router.get("", response_model=EntityPagination)
2020
def get_entities(common: CommonParameters):
21-
"""Get all entitys, or only those matching a given search term."""
21+
"""Get all entities, or only those matching a given search term."""
2222
return search_filter_sort_paginate(model="Entity", **common)
2323

2424

@@ -42,7 +42,7 @@ def create_entity(db_session: DbSession, entity_in: EntityCreate):
4242

4343
@router.put("/{entity_id}", response_model=EntityRead)
4444
def update_entity(db_session: DbSession, entity_id: PrimaryKey, entity_in: EntityUpdate):
45-
"""Updates an exisiting entity."""
45+
"""Updates an existing entity."""
4646
entity = get(db_session=db_session, entity_id=entity_id)
4747
if not entity:
4848
raise HTTPException(

0 commit comments

Comments
 (0)