Skip to content

Commit 71b998e

Browse files
authored
Merge pull request #519 from NHSDigital/chore/eja-eli-366-address-ruff-issues-with-version-bump
eli-366 addressing ruff failures with updated version of ruff
2 parents d91fec5 + 74b9325 commit 71b998e

11 files changed

Lines changed: 33 additions & 34 deletions

File tree

poetry.lock

Lines changed: 21 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ botocore = "^1.40.57"
3737
aws-xray-sdk = "2.15.0"
3838

3939
[tool.poetry.group.dev.dependencies]
40-
ruff = "^0.11.13"
40+
ruff = "^0.14.10"
4141
docopt = "^0.6.2"
4242
jsonpath-rw = "^1.4.0"
4343
semver = "^3.0.4"

scripts/config/pre-commit.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ repos:
5151
language: script
5252
pass_filenames: false
5353
- repo: https://github.com/astral-sh/ruff-pre-commit
54-
rev: v0.9.7
54+
rev: v0.14.10
5555
hooks:
5656
- id: ruff
5757
args: [--fix]

src/eligibility_signposting_api/model/campaign_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class IterationRule(BaseModel):
158158
model_config = {"populate_by_name": True, "extra": "ignore"}
159159

160160
@field_validator("rule_stop", mode="before")
161-
def parse_yn_to_bool(cls, v: str | bool) -> bool: # noqa: N805
161+
def parse_yn_to_bool(cls, v: str | bool) -> bool: # noqa: N805, FBT001
162162
if isinstance(v, str):
163163
return v.upper() == "Y"
164164
return v

src/eligibility_signposting_api/services/calculators/eligibility_calculator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def get_best_iteration_result(self, campaign_group: list[CampaignConfig]) -> Bes
129129
if not iteration_results:
130130
return None
131131

132-
(best_iteration_name, best_iteration_result) = max(
132+
(_best_iteration_name, best_iteration_result) = max(
133133
iteration_results.items(),
134134
key=lambda item: next(iter(item[1].cohort_results.values())).status.value
135135
# Below handles the case where there are no cohort results

tests/integration/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def iam_role(iam_client: BaseClient) -> Generator[str]:
228228

229229
@pytest.fixture(scope="session")
230230
def lambda_zip() -> Path:
231-
build_result = subprocess.run(["make", "build"], capture_output=True, text=True, check=False) # Noqa: S603, S607
231+
build_result = subprocess.run(["make", "build"], capture_output=True, text=True, check=False) # noqa: S607
232232
assert build_result.returncode == 0, f"'make build' failed: {build_result.stderr}"
233233
return Path("dist/lambda.zip")
234234

tests/unit/logging/test_logs_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import pytest
66
from mangum.types import LambdaContext
77

8+
from eligibility_signposting_api.app import log_request_ids_from_headers
9+
810

911
@pytest.fixture
1012
def lambda_context():
@@ -46,8 +48,6 @@ def lambda_context():
4648
],
4749
)
4850
def test_log_request_ids_decorator_logs_metadata(headers, gateway_request_id, expected_extra, lambda_context, caplog):
49-
from eligibility_signposting_api.app import log_request_ids_from_headers
50-
5151
event = {"headers": headers}
5252
if gateway_request_id is not None:
5353
event["requestContext"] = {"requestId": gateway_request_id}

tests/unit/middleware/test_security_headers.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from http import HTTPStatus
44

55
import pytest
6-
from flask import Flask
6+
from flask import Flask, make_response
77
from flask.testing import FlaskClient
88
from hamcrest import assert_that, contains_string, equal_to, has_entries, is_
99

@@ -152,8 +152,6 @@ def test_existing_headers_are_not_overridden(self) -> None:
152152

153153
@app.route("/test")
154154
def test_route():
155-
from flask import make_response
156-
157155
resp = make_response({"status": "ok"}, HTTPStatus.OK)
158156
resp.headers["Cache-Control"] = "public, max-age=3600"
159157
return resp

tests/unit/services/calculators/test_eligibility_calculator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ def test_eligibility_status_with_invalid_tokens_raises_attribute_error(faker: Fa
14361436

14371437
calculator = EligibilityCalculator(person_rows, campaign_configs)
14381438

1439-
with pytest.raises(ValueError, match="Invalid token."):
1439+
with pytest.raises(ValueError, match=r"Invalid token format\."):
14401440
calculator.get_eligibility_status("Y", ["ALL"], "ALL")
14411441

14421442

tests/unit/services/processors/test_token_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_parse_valid_tokens(self, token, expected_level, expected_name, expected
3838
],
3939
)
4040
def test_parse_invalid_tokens_raises_error(self, token):
41-
with pytest.raises(ValueError, match="Invalid token."):
41+
with pytest.raises(ValueError, match=r"Invalid token\."):
4242
TokenParser.parse(token)
4343

4444
@pytest.mark.parametrize(
@@ -53,5 +53,5 @@ def test_parse_invalid_tokens_raises_error(self, token):
5353
],
5454
)
5555
def test_parse_invalid_token_format_raises_error(self, token):
56-
with pytest.raises(ValueError, match="Invalid token format."):
56+
with pytest.raises(ValueError, match=r"Invalid token format\."):
5757
TokenParser.parse(token)

0 commit comments

Comments
 (0)