diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e58e2b61..37a8eee2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,4 @@ -# This file was automatically copied from notifications-utils@92.1.1 +# This file was automatically copied from notifications-utils@94.0.1 repos: - repo: https://github.com/pre-commit/pre-commit-hooks @@ -9,12 +9,8 @@ repos: - id: check-yaml - id: debug-statements - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.8.2' + rev: 'v0.9.2' hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] -- repo: https://github.com/psf/black - rev: 24.10.0 - hooks: - - id: black - name: black (python) + - id: ruff-format diff --git a/Makefile b/Makefile index 439c0cc9..9a60bd90 100644 --- a/Makefile +++ b/Makefile @@ -55,8 +55,7 @@ run-celery-with-docker: ## Run celery in Docker container .PHONY: test test: ## Run tests (used by Concourse) ruff check . - black --check . - + ruff format --check . pytest -n auto --maxfail=10 .PHONY: test-with-docker diff --git a/app/__init__.py b/app/__init__.py index b6ebf390..2708ac6e 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -7,11 +7,11 @@ from flask import Flask, jsonify from flask_httpauth import HTTPTokenAuth from gds_metrics import GDSMetrics -from notifications_utils import logging as utils_logging from notifications_utils import request_helper from notifications_utils.celery import NotifyCelery from notifications_utils.clients.signing.signing_client import Signing from notifications_utils.clients.statsd.statsd_client import StatsdClient +from notifications_utils.logging import flask as utils_logging from notifications_utils.s3 import S3ObjectNotFound, s3download, s3upload from app import weasyprint_hack diff --git a/app/celery/tasks.py b/app/celery/tasks.py index 85b70754..8a311238 100644 --- a/app/celery/tasks.py +++ b/app/celery/tasks.py @@ -115,7 +115,7 @@ def copy_s3_object(source_bucket, source_filename, target_bucket, target_filenam def _create_pdf_for_letter( task: Task, letter_details, language: Literal["english", "welsh"], include_notify_tag: bool = True ): - logo_filename = f'{letter_details["logo_filename"]}.svg' if letter_details["logo_filename"] else None + logo_filename = f"{letter_details['logo_filename']}.svg" if letter_details["logo_filename"] else None template = LetterPrintTemplate( letter_details["template"], values=letter_details["values"] or None, diff --git a/app/embedded_fonts.py b/app/embedded_fonts.py index 4ca59ad7..4a24a4e9 100644 --- a/app/embedded_fonts.py +++ b/app/embedded_fonts.py @@ -110,6 +110,6 @@ def embed_fonts(pdf_data): raise Exception( f"ghostscript font embed process failed with return code: {gs_process.returncode}\n" f"stderr:\n" - f'{stderr.decode("utf-8")}' + f"{stderr.decode('utf-8')}" ) return BytesIO(stdout) diff --git a/app/preview.py b/app/preview.py index 0d7f76ac..fe31132d 100644 --- a/app/preview.py +++ b/app/preview.py @@ -200,7 +200,7 @@ def _get_pdf_from_letter_json(letter_json, language="english") -> BytesIO: def get_html(json, language="english"): - branding_filename = f'{json["filename"]}.svg' if json["filename"] else None + branding_filename = f"{json['filename']}.svg" if json["filename"] else None return str( LetterPreviewTemplate( diff --git a/requirements.in b/requirements.in index 23a5a170..757dfd32 100644 --- a/requirements.in +++ b/requirements.in @@ -17,7 +17,7 @@ PyMuPDF==1.24.4 WeasyPrint==59 # Run `make bump-utils` to update to the latest version -notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@92.1.1 +notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@94.0.1 # gds-metrics requires prometheseus 0.2.0, override that requirement as 0.7.1 brings significant performance gains prometheus-client==0.14.1 diff --git a/requirements.txt b/requirements.txt index 1a1910a7..8e4d71ae 100644 --- a/requirements.txt +++ b/requirements.txt @@ -110,7 +110,7 @@ markupsafe==2.1.5 # werkzeug mistune==0.8.4 # via notifications-utils -notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@b9ef1b45b655324d6341995afffc3ebc25a3ed72 +notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@d6311c3ab83b8225265277f781157c48f9318ae9 # via -r requirements.in ordered-set==4.1.0 # via notifications-utils diff --git a/requirements_for_test.txt b/requirements_for_test.txt index 0337e25d..a6ae617f 100644 --- a/requirements_for_test.txt +++ b/requirements_for_test.txt @@ -18,8 +18,6 @@ billiard==4.2.0 # via # -r requirements.txt # celery -black==24.10.0 - # via -r requirements_for_test_common.in blinker==1.9.0 # via # -r requirements.txt @@ -63,7 +61,6 @@ charset-normalizer==3.3.2 click==8.1.7 # via # -r requirements.txt - # black # celery # click-didyoumean # click-plugins @@ -178,9 +175,7 @@ mistune==0.8.4 # notifications-utils moto==4.1.5 # via -r requirements_for_test.in -mypy-extensions==1.0.0 - # via black -notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@b9ef1b45b655324d6341995afffc3ebc25a3ed72 +notifications-utils @ git+https://github.com/alphagov/notifications-utils.git@d6311c3ab83b8225265277f781157c48f9318ae9 # via -r requirements.txt ordered-set==4.1.0 # via @@ -189,11 +184,8 @@ ordered-set==4.1.0 packaging==24.1 # via # -r requirements.txt - # black # gunicorn # pytest -pathspec==0.12.1 - # via black pdf2image==1.12.1 # via -r requirements.txt phonenumbers==8.13.51 @@ -206,8 +198,6 @@ pillow==9.3.0 # pdf2image # reportlab # weasyprint -platformdirs==4.3.6 - # via black pluggy==1.5.0 # via pytest prometheus-client==0.14.1 @@ -300,7 +290,7 @@ requests-mock==1.12.1 # via -r requirements_for_test_common.in responses==0.25.3 # via moto -ruff==0.8.2 +ruff==0.9.2 # via -r requirements_for_test_common.in s3transfer==0.10.1 # via diff --git a/requirements_for_test_common.in b/requirements_for_test_common.in index d424c600..e660e7e4 100644 --- a/requirements_for_test_common.in +++ b/requirements_for_test_common.in @@ -1,4 +1,4 @@ -# This file was automatically copied from notifications-utils@92.1.1 +# This file was automatically copied from notifications-utils@94.0.1 beautifulsoup4==4.12.3 pytest==8.3.4 @@ -9,5 +9,4 @@ pytest-testmon==2.1.1 requests-mock==1.12.1 freezegun==1.5.1 -black==24.10.0 # Also update `.pre-commit-config.yaml` if this changes -ruff==0.8.2 # Also update `.pre-commit-config.yaml` if this changes +ruff==0.9.2 # Also update `.pre-commit-config.yaml` if this changes diff --git a/pyproject.toml b/ruff.toml similarity index 81% rename from pyproject.toml rename to ruff.toml index a98c29c9..77c6085c 100644 --- a/pyproject.toml +++ b/ruff.toml @@ -1,14 +1,22 @@ -# This file was automatically copied from notifications-utils@92.1.1 +# This file was automatically copied from notifications-utils@94.0.1 -[tool.black] -line-length = 120 +exclude = [ + "migrations/versions/", + "venv*", + "__pycache__", + "node_modules", + "cache", + "migrations", + "build", + "sample_cap_xml_documents.py", +] -[tool.ruff] line-length = 120 target-version = "py311" -lint.select = [ +[lint] +select = [ "E", # pycodestyle "W", # pycodestyle "F", # pyflakes @@ -24,14 +32,4 @@ lint.select = [ "PIE", # flake8-pie "N804", # First argument of a class method should be named `cls` ] -lint.ignore = [] -exclude = [ - "migrations/versions/", - "venv*", - "__pycache__", - "node_modules", - "cache", - "migrations", - "build", - "sample_cap_xml_documents.py", -] +ignore = []