Skip to content

Commit

Permalink
Merge branch 'main' into fix/perf-test-dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
jzbahrai authored Jan 31, 2025
2 parents 383c108 + 2253857 commit 875efac
Show file tree
Hide file tree
Showing 62 changed files with 818 additions and 803 deletions.
18 changes: 9 additions & 9 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@
"customizations": {
"vscode": {
"settings": {
"ruff.lint.ignore": ["F401"],
"ruff.lint.run": "onSave",
"ruff.organizeImports": false,
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
}
"editor.formatOnSave": true
},
"python.formatting.blackPath": "/usr/local/bin/black",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.linting.pylintPath": "/usr/local/bin/pylint",
"python.pythonPath": "/usr/local/bin/python"
},
"extensions": [
"tamasfe.even-better-toml",
"bungcip.better-toml",
"donjayamanne.python-extension-pack",
"-ms-python.autopep8",
"eamodio.gitlens",
"fill-labs.dependi",
"GitHub.copilot",
Expand All @@ -42,8 +43,7 @@
"visualstudioexptteam.vscodeintellicode",
"wenfangdu.jump",
"wholroyd.jinja",
"yzhang.markdown-all-in-one",
"charliermarsh.ruff"
"yzhang.markdown-all-in-one"
]
}
},
Expand Down
9 changes: 1 addition & 8 deletions .devcontainer/scripts/notify-dev-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@ echo -e "# fzf key bindings and completion" >> ~/.zshrc
echo -e "source /usr/share/doc/fzf/examples/key-bindings.zsh" >> ~/.zshrc
echo -e "source /usr/share/doc/fzf/examples/completion.zsh" >> ~/.zshrc


cd /workspace

# Poetry autocomplete
echo -e "fpath+=/.zfunc" >> ~/.zshrc
echo -e "autoload -Uz compinit && compinit"

pip install poetry=="${POETRY_VERSION}" poetry-plugin-sort
pip install poetry==${POETRY_VERSION}
export PATH=$PATH:/home/vscode/.local/bin/
which poetry
poetry --version
Expand All @@ -53,15 +52,9 @@ poetry completions zsh > ~/.zfunc/_poetry

make generate-version-file

# Set up git blame to ignore certain revisions e.g. sweeping code formatting changes.
git config blame.ignoreRevsFile .git-blame-ignore-revs

# Install dependencies
poetry install

# Install pre-commit hooks
poetry run pre-commit install

# Upgrade schema of the notification_api database.
poetry run flask db upgrade

Expand Down
11 changes: 0 additions & 11 deletions .git-blame-ignore-revs

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Install poetry
env:
POETRY_VERSION: "1.7.1"
run: pip install poetry==${POETRY_VERSION} poetry-plugin-sort && poetry --version
run: pip install poetry==${POETRY_VERSION} && poetry --version
- name: Check poetry.lock aligns with pyproject.toml
run: poetry check --lock
- name: Install requirements
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,3 @@ jinja_templates/
cypress.env.json
node_modules/
tests_cypress/cypress/videos/

.ruff_cache/
9 changes: 0 additions & 9 deletions .pre-commit-config.yaml

This file was deleted.

8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ clean:

.PHONY: format
format:
ruff check --fix .
ruff check
ruff format .
mypy ./
poetry run isort .
poetry run black --config pyproject.toml .
poetry run flake8 .
poetry run mypy .

.PHONY: smoke-test
smoke-test:
Expand Down
6 changes: 3 additions & 3 deletions app/celery/scheduled_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ def replay_created_notifications():

if len(notifications_to_resend) > 0:
current_app.logger.info(
"Sending {} {} notifications " "to the delivery queue because the notification " "status was created.".format(
len(notifications_to_resend), notification_type
)
"Sending {} {} notifications "
"to the delivery queue because the notification "
"status was created.".format(len(notifications_to_resend), notification_type)
)

for n in notifications_to_resend:
Expand Down
4 changes: 3 additions & 1 deletion app/celery/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,9 @@ def send_inbound_sms_to_service(self, inbound_sms_id, service_id):
except self.MaxRetriesExceededError:
current_app.logger.error(
"""Retry: send_inbound_sms_to_service has retried the max number of
times for service: {} and inbound_sms {}""".format(service_id, inbound_sms_id)
times for service: {} and inbound_sms {}""".format(
service_id, inbound_sms_id
)
)


Expand Down
2 changes: 1 addition & 1 deletion app/encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def init_app(self, app: Any, secret_key: str | List[str], salt: str) -> None:
salt (str): The salt to use for signing.
"""
self.app = app
self.secret_key = cast(List[str], [secret_key] if isinstance(secret_key, str) else secret_key)
self.secret_key = cast(List[str], [secret_key] if type(secret_key) is str else secret_key)
self.serializer = URLSafeSerializer(secret_key)
self.salt = salt

Expand Down
1 change: 0 additions & 1 deletion app/history_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
session events.
"""

import datetime

from sqlalchemy import Column, ForeignKeyConstraint, Integer, Table, util
Expand Down
4 changes: 2 additions & 2 deletions app/service/callback_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ def handle_sql_error(e, table_name):
and hasattr(e.orig, "pgerror")
and e.orig.pgerror
and (
'insert or update on table "{0}" violates ' 'foreign key constraint "{0}_service_id_fkey"'.format(table_name)
in e.orig.pgerror
'insert or update on table "{0}" violates '
'foreign key constraint "{0}_service_id_fkey"'.format(table_name) in e.orig.pgerror
)
):
return jsonify(result="error", message="No result found"), 404
Expand Down
1 change: 1 addition & 0 deletions app/service/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
over_email_daily_limit_cache_key,
over_sms_daily_limit_cache_key,
)
from notifications_utils.timezones import convert_utc_to_local_timezone
from sqlalchemy import func
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm.exc import NoResultFound
Expand Down
3 changes: 2 additions & 1 deletion app/v2/notifications/post_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
email_normal_publish,
email_priority_publish,
notify_celery,
redis_store,
signer_notification,
sms_bulk_publish,
sms_normal_publish,
Expand Down Expand Up @@ -685,7 +686,7 @@ def get_reply_to_text(notification_type, form, template, form_field=None):


def strip_keys_from_personalisation_if_send_attach(personalisation):
return {k: v for (k, v) in personalisation.items() if not (isinstance(v, dict) and v.get("sending_method") == "attach")}
return {k: v for (k, v) in personalisation.items() if not (type(v) is dict and v.get("sending_method") == "attach")}


def check_for_csv_errors(recipient_csv, max_rows, remaining_daily_messages, remaining_annual_messages):
Expand Down
4 changes: 3 additions & 1 deletion gunicorn_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ def worker_abort(worker):
def on_exit(server):
elapsed_time = time.time() - start_time
server.log.info("Stopping Notifications API")
server.log.info("Total gunicorn API running time: {:.2f} seconds".format(elapsed_time))
server.log.info(
"Total gunicorn API running time: {:.2f} seconds".format(elapsed_time)
)


def worker_int(worker):
Expand Down
Loading

0 comments on commit 875efac

Please sign in to comment.