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

Updates pre-commit hooks versions and fixes typos and formatting #5277

Merged
merged 1 commit into from
Oct 1, 2024
Merged
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ yarn.lock

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

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

### Vim ###
# Swap
Expand Down
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ default_language_version:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.4
# ruff version.
rev: v0.6.4
hooks:
# Run the linter.
#
Expand All @@ -28,9 +28,10 @@ repos:

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

# Pytest
- repo: local
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ COPY --from=sdist /dist/*.whl /tmp/dist/
RUN buildDeps="" \
&& apt-get update \
&& apt-get install -y --no-install-recommends "$buildDeps" \
# remove internal index when internal plugins are seperated
# remove internal index when internal plugins are separated
&& pip install -U /tmp/dist/*.whl \
&& apt-get purge -y --auto-remove "$buildDeps" \
# We install run-time dependencies strictly after
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/administration/contributing/core.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Folder Structure

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\).
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\).

```text
├── dispatch
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/administration/settings/case/case-type.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Dispatch allows you to categorize your cases by defining case types and to map t

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

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

**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.

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/administration/settings/cost_model.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ If an incident type does not have a specific cost model assigned, the default cl
## Key Features

### Customizable Cost Models
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.
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.

### Plugin-Based Tracking
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.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/administration/settings/knowledge/runbooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Today, there are two types of runbooks although their actual usage is the same.

### Engagement

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.
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.

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

Expand Down
4 changes: 2 additions & 2 deletions docs/docs/administration/settings/signal/definition.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Signal Definition

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

## Sending Signals to Dispatch

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

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

**Variant**: The same signal can have multiple varitants with different defintions.
**Variant**: The same signal can have multiple varitants with different definitions.

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Engagement Filter

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.
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.

### Creating an Engagement Filter

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/administration/user.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Users or organizational members represent users of the Dispatch UI and are diffe

</div>

**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:
**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:

- Member: Can access everything except restricted incidents unless they are a direct participant.
- Admin: Allows full access to the Dispatch UI and all incidents, whether their visibility is open or restricted.
Expand Down
8 changes: 4 additions & 4 deletions docs/scripts/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13044,7 +13044,7 @@ paths:
- documents
/{organization}/entity:
get:
description: Get all entitys, or only those matching a given search term.
description: Get all entities, or only those matching a given search term.
operationId: get_entities__organization__entity_get
parameters:
- in: path
Expand Down Expand Up @@ -13350,7 +13350,7 @@ paths:
tags:
- entities
put:
description: Updates an exisiting entity.
description: Updates an existing entity.
operationId: update_entity__organization__entity__entity_id__put
parameters:
- in: path
Expand Down Expand Up @@ -14548,7 +14548,7 @@ paths:
tags:
- feedback
put:
description: Updates a feeback entry by its id.
description: Updates a feedback entry by its id.
operationId: update_feedback__organization__feedback__feedback_id__put
parameters:
- in: path
Expand Down Expand Up @@ -21315,7 +21315,7 @@ paths:
tags:
- tags
put:
description: Updates an exisiting tag.
description: Updates an existing tag.
operationId: update_tag__organization__tags__tag_id__put
parameters:
- in: path
Expand Down
1 change: 1 addition & 0 deletions src/dispatch/auth/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
:copyright: (c) 2019 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
"""

import logging
from typing import Annotated, Optional

Expand Down
17 changes: 7 additions & 10 deletions src/dispatch/case/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
:copyright: (c) 2019 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
"""

import logging

from sqlalchemy.orm import Session
Expand All @@ -29,7 +30,9 @@
from dispatch.plugin import service as plugin_service
from dispatch.event import service as event_service
from dispatch.notification import service as notification_service
from dispatch.plugins.dispatch_slack.case.messages import create_welcome_ephemeral_message_to_participant
from dispatch.plugins.dispatch_slack.case.messages import (
create_welcome_ephemeral_message_to_participant,
)

from .enums import CaseStatus

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

case_description = (
case.description
if len(case.description) <= 500
else f"{case.description[:500]}..."
case.description if len(case.description) <= 500 else f"{case.description[:500]}..."
)

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


def send_case_update_notifications(
case: Case, previous_case: CaseRead, db_session: Session
):
def send_case_update_notifications(case: Case, previous_case: CaseRead, db_session: Session):
"""Sends notifications about case changes."""
notification_text = "Case Notification"
notification_type = MessageType.case_notification
Expand Down Expand Up @@ -319,9 +318,7 @@ def send_case_welcome_participant_message(
)

if not plugin:
log.warning(
"Case participant welcome message not sent. No conversation plugin enabled."
)
log.warning("Case participant welcome message not sent. No conversation plugin enabled.")
return

welcome_message = create_welcome_ephemeral_message_to_participant(case=case)
Expand Down
3 changes: 1 addition & 2 deletions src/dispatch/case_cost/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def update_case_response_cost_for_case_type(db_session, case_type: CaseType) ->

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


def get_default_case_response_cost(case: Case, db_session: SessionLocal) -> Optional[CaseCost]:
Expand Down Expand Up @@ -223,7 +223,6 @@ def calculate_case_response_cost_with_cost_model(case: Case, db_session: Session
if case.case_type.cost_model:
# Get the cost model. Iterate through all the listed activities we want to record.
for activity in case.case_type.cost_model.activities:

# Array of sorted (timestamp, user_id) tuples.
case_events = fetch_case_events(
case=case, activity=activity, oldest=oldest, db_session=db_session
Expand Down
8 changes: 4 additions & 4 deletions src/dispatch/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,9 @@ def drop_database():
"""Drops all data in database."""
from sqlalchemy_utils import database_exists, drop_database

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

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


@dispatch_database.command("upgrade")
Expand Down
1 change: 1 addition & 0 deletions src/dispatch/common/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

.. moduleauthor:: Kevin Glisson <[email protected]>
"""

import logging
from dispatch.exceptions import InvalidConfigurationError

Expand Down
2 changes: 1 addition & 1 deletion src/dispatch/cost_model/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def update(*, db_session, cost_model_in: CostModelUpdate) -> CostModel:
cost_model_in.updated_at if cost_model_in.updated_at else datetime.utcnow()
)

# Update all recognized activities. Delete all removed activites.
# Update all recognized activities. Delete all removed activities.
update_activities = []
delete_activities = []

Expand Down
2 changes: 1 addition & 1 deletion src/dispatch/data/query/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_by_name_or_raise(*, db_session, query_in: QueryRead, project_id: int) ->


def get_all(*, db_session):
"""Gets all querys."""
"""Gets all queries."""
return db_session.query(Query)


Expand Down
1 change: 1 addition & 0 deletions src/dispatch/data/source/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class QueryReadMinimal(DispatchBase):
name: str
description: str


class Link(DispatchBase):
id: Optional[int]
name: Optional[str]
Expand Down
1 change: 1 addition & 0 deletions src/dispatch/data/source/scheduled.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
:copyright: (c) 2022 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
"""

import logging

from schedule import every
Expand Down
5 changes: 3 additions & 2 deletions src/dispatch/database/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,9 @@ def build_filters(filter_spec):

if not _is_iterable_filter(fn_args):
raise BadFilterFormat(
"`{}` value must be an iterable across the function "
"arguments".format(boolean_function.key)
"`{}` value must be an iterable across the function " "arguments".format(
boolean_function.key
)
)
if boolean_function.only_one_arg and len(fn_args) != 1:
raise BadFilterFormat(
Expand Down
8 changes: 4 additions & 4 deletions src/dispatch/email_templates/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def get(*, email_template_id: int, db_session: Session) -> Optional[EmailTemplat
)


def get_by_type(*, email_template_type: str, project_id: int, db_session: Session) -> Optional[EmailTemplates]:
def get_by_type(
*, email_template_type: str, project_id: int, db_session: Session
) -> Optional[EmailTemplates]:
"""Gets an email template by its type."""
return (
db_session.query(EmailTemplates)
Expand All @@ -40,9 +42,7 @@ def create(*, email_template_in: EmailTemplatesCreate, db_session: Session) -> E
db_session=db_session, project_in=email_template_in.project
)

email_template = EmailTemplates(
**email_template_in.dict(exclude={"project"}), project=project
)
email_template = EmailTemplates(**email_template_in.dict(exclude={"project"}), project=project)

db_session.add(email_template)
db_session.commit()
Expand Down
15 changes: 10 additions & 5 deletions src/dispatch/email_templates/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
from dispatch.models import PrimaryKey
from dispatch.exceptions import ExistsError

from .models import EmailTemplatesRead, EmailTemplatesUpdate, EmailTemplatesPagination, EmailTemplatesCreate
from .models import (
EmailTemplatesRead,
EmailTemplatesUpdate,
EmailTemplatesPagination,
EmailTemplatesCreate,
)
from .service import get, create, update, delete

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -47,9 +52,7 @@ def create_email_template(
):
"""Create a new email template."""
try:
return create(
db_session=db_session, email_template_in=email_template_in
)
return create(db_session=db_session, email_template_in=email_template_in)
except IntegrityError:
raise ValidationError(
[
Expand Down Expand Up @@ -80,7 +83,9 @@ def update_email_template(
)
try:
email_template = update(
db_session=db_session, email_template=email_template, email_template_in=email_template_in
db_session=db_session,
email_template=email_template,
email_template_in=email_template_in,
)
except IntegrityError:
raise ValidationError(
Expand Down
4 changes: 2 additions & 2 deletions src/dispatch/entity/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

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


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

@router.put("/{entity_id}", response_model=EntityRead)
def update_entity(db_session: DbSession, entity_id: PrimaryKey, entity_in: EntityUpdate):
"""Updates an exisiting entity."""
"""Updates an existing entity."""
entity = get(db_session=db_session, entity_id=entity_id)
if not entity:
raise HTTPException(
Expand Down
Loading
Loading