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

Experiment - Add Ruff formatter/linter #2114

Merged
merged 26 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9848ead
Add Ruff formatter/linter
whabanks Feb 16, 2024
269c0a0
Rearrange
whabanks Feb 16, 2024
c1f190b
Check in offensive code (offensive for the Ruff linter)
whabanks Feb 16, 2024
89446d9
Add formatter configs, run formatter
whabanks Feb 19, 2024
2a37c7a
Merge branch 'main' into experiment/migrate-to-ruff
whabanks Feb 23, 2024
4cd1d18
Fix deps and mishap from the poetry bump during merge
whabanks Feb 23, 2024
0c2ec1b
Merge branch 'main' into experiment/migrate-to-ruff
whabanks Feb 23, 2024
477b823
fix tests
whabanks Feb 23, 2024
4a62bce
Update build tool from poetry to poetry-core per docs
whabanks Feb 23, 2024
11b275f
Move ruff formatter configs to the bottom of pyproject.toml
whabanks May 24, 2024
3ed6edb
Merge branch 'main' into experiment/migrate-to-ruff
whabanks May 24, 2024
adeccff
Fix botched merge the downgraded recently bumped deps
whabanks May 24, 2024
054d7fa
Merge remote-tracking branch 'origin/main' into experiment/migrate-to…
whabanks Jun 21, 2024
32b270e
Fix pyproject.toml, resort, and regen lock file
whabanks Jun 21, 2024
c8fe7b4
Remove file that got re-added during merge..somehow
whabanks Jun 21, 2024
01c5dc3
Formatting
whabanks Jun 21, 2024
7913a9d
Re-add Flask-Marshmallow...update lock file
whabanks Jun 21, 2024
715ccfd
Merge branch 'main' into experiment/migrate-to-ruff
whabanks Jul 2, 2024
cce9e92
Merge branch 'main' into experiment/migrate-to-ruff
whabanks Jul 5, 2024
6865a85
Merge branch 'main' into experiment/migrate-to-ruff
whabanks Jul 30, 2024
85649ef
Merge branch 'main' into experiment/migrate-to-ruff
whabanks Jul 30, 2024
0b7c2fc
update lockfile
whabanks Jul 30, 2024
d342a51
Merge branch 'main' into experiment/migrate-to-ruff
whabanks Jul 30, 2024
bf55663
Merge branch 'main' into experiment/migrate-to-ruff
whabanks Sep 12, 2024
eb24570
Fix deps, regen lock file
whabanks Sep 12, 2024
00c62a9
Update format make target
whabanks Sep 12, 2024
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
10 changes: 3 additions & 7 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@
"[python]": {
"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": [
"bungcip.better-toml",
"tamasfe.even-better-toml",
"donjayamanne.python-extension-pack",
"eamodio.gitlens",
"GitHub.copilot",
Expand All @@ -41,7 +37,8 @@
"visualstudioexptteam.vscodeintellicode",
"wenfangdu.jump",
"wholroyd.jinja",
"yzhang.markdown-all-in-one"
"yzhang.markdown-all-in-one",
"charliermarsh.ruff"
]
}
},
Expand All @@ -61,5 +58,4 @@
},
"postCreateCommand": "notify-dev-entrypoint.sh",
"remoteUser": "vscode",

}
2 changes: 1 addition & 1 deletion .devcontainer/scripts/notify-dev-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ cd /workspace
echo -e "fpath+=/.zfunc" >> ~/.zshrc
echo -e "autoload -Uz compinit && compinit"

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

.ruff_cache/
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ clean:

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

.PHONY: 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: 1 addition & 3 deletions app/celery/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,7 @@ 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 type(secret_key) is str else secret_key)
self.secret_key = cast(List[str], [secret_key] if isinstance(secret_key, str) else secret_key)
self.serializer = URLSafeSerializer(secret_key)
self.salt = salt

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 @@ -148,8 +148,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
4 changes: 1 addition & 3 deletions app/v2/notifications/post_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
email_normal_publish,
email_priority_publish,
notify_celery,
redis_store,
signer_notification,
sms_bulk_publish,
sms_normal_publish,
Expand Down Expand Up @@ -62,7 +61,6 @@
Notification,
NotificationType,
Service,
TemplateType,
)
from app.notifications.process_letter_notifications import create_letter_notification
from app.notifications.process_notifications import (
Expand Down Expand Up @@ -661,7 +659,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 (type(v) is dict and v.get("sending_method") == "attach")}
return {k: v for (k, v) in personalisation.items() if not (isinstance(v, dict) and v.get("sending_method") == "attach")}


def check_for_csv_errors(recipient_csv, max_rows, remaining_messages):
Expand Down
148 changes: 27 additions & 121 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading