Skip to content

Commit

Permalink
Merge pull request #913 from communitiesuk/renovate/ruff-updates
Browse files Browse the repository at this point in the history
Update Ruff updates to v0.9.2
  • Loading branch information
samuelhwilliams authored Jan 21, 2025
2 parents d039bf6 + f4ed69d commit 846fcd7
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
- id: check-ast
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version. If bumping this, please also bump requirements-dev.in
rev: v0.8.4
rev: v0.9.2
hooks:
# Run the linter.
- id: ruff
Expand Down
2 changes: 1 addition & 1 deletion data_store/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ class OrganisationTypeEnum(StrEnum):
OUTPUT_CATEGORIES = {
"# of additional enterprises with broadband access of at least 30mbps": "Regeneration - Community Infrastructure",
(
"# of additional residential units " "with broadband access of at least 30mbps"
"# of additional residential units with broadband access of at least 30mbps"
): "Regeneration - Community Infrastructure",
"# of alternative fuel charging/re-fuelling points": "Transport",
"# of derelict buildings refurbished": "Regeneration - Estate Renewal",
Expand Down
2 changes: 1 addition & 1 deletion data_store/messaging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class SharedMessages:
"Select an option from the dropdown list."
)
DUPLICATION = "You entered duplicate data. Remove or replace the duplicate data."
UNAUTHORISED = "You’re not authorised to submit for {entered_value}. You can only submit for " "{allowed_values}."
UNAUTHORISED = "You’re not authorised to submit for {entered_value}. You can only submit for {allowed_values}."
NEGATIVE_NUMBER = "You’ve entered a negative number. Enter a positive number."
POSTCODE = "You entered an invalid postcode. Enter a full UK postcode, for example SW1A 2AA."
INVALID_PROJECT_DATES = "The project start date cannot be after the project completion date."
Expand Down
2 changes: 1 addition & 1 deletion data_store/messaging/tf_messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def _wrong_type_failure_message(self, validation_failure: WrongTypeFailure) -> M
if sheet == "Outcomes":
_, section = (
"Financial Year 2022/21 - Financial Year 2029/30",
("Outcome Indicators (excluding " "footfall) and Footfall Indicator"),
("Outcome Indicators (excluding footfall) and Footfall Indicator"),
)

cell_index = (
Expand Down
24 changes: 8 additions & 16 deletions data_store/validation/initial_validation/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,15 @@
row=6,
column=4,
expected_values=(),
error_message="You’re not authorised to submit for {entered_value}. You can only submit for "
"{allowed_values}.",
error_message="You’re not authorised to submit for {entered_value}. You can only submit for {allowed_values}.",
auth_type="Fund Types",
),
AuthorisationCheck(
sheet="2 - Project Admin",
row=7,
column=4,
expected_values=(),
error_message="You’re not authorised to submit for {entered_value}. You can only "
"submit for {allowed_values}.",
error_message="You’re not authorised to submit for {entered_value}. You can only submit for {allowed_values}.",
auth_type="Place Names",
),
]
Expand Down Expand Up @@ -189,17 +187,15 @@
row=6,
column=4,
expected_values=(),
error_message="You’re not authorised to submit for {entered_value}. You can only submit for "
"{allowed_values}.",
error_message="You’re not authorised to submit for {entered_value}. You can only submit for {allowed_values}.",
auth_type="Fund Types",
),
AuthorisationCheck(
sheet="2 - Project Admin",
row=7,
column=4,
expected_values=(),
error_message="You’re not authorised to submit for {entered_value}. You can only "
"submit for {allowed_values}.",
error_message="You’re not authorised to submit for {entered_value}. You can only submit for {allowed_values}.",
auth_type="Place Names",
),
]
Expand Down Expand Up @@ -261,17 +257,15 @@
row=6,
column=4,
expected_values=(),
error_message="You’re not authorised to submit for {entered_value}. You can only submit for "
"{allowed_values}.",
error_message="You’re not authorised to submit for {entered_value}. You can only submit for {allowed_values}.",
auth_type="Fund Types",
),
AuthorisationCheck(
sheet="2 - Project Admin",
row=7,
column=4,
expected_values=(),
error_message="You’re not authorised to submit for {entered_value}. You can only "
"submit for {allowed_values}.",
error_message="You’re not authorised to submit for {entered_value}. You can only submit for {allowed_values}.",
auth_type="Place Names",
),
]
Expand All @@ -298,8 +292,7 @@
row=14,
column=1,
expected_values=(),
error_message="You’re not authorised to submit for {entered_value}. You can only "
"submit for {allowed_values}.",
error_message="You’re not authorised to submit for {entered_value}. You can only submit for {allowed_values}.",
auth_type="Programme",
),
BasicCheck(
Expand Down Expand Up @@ -339,8 +332,7 @@
row=19,
column=1,
expected_values=(),
error_message="You’re not authorised to submit for {entered_value}. You can only "
"submit for {allowed_values}.",
error_message="You’re not authorised to submit for {entered_value}. You can only submit for {allowed_values}.",
auth_type="Programme",
),
]
11 changes: 4 additions & 7 deletions data_store/validation/towns_fund/failures/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def __str__(self):
"""
Method to get the string representation of the extra table failure.
"""
return (
"Extra Table Failure: The data included a table named" f'"{self.extra_table}" but it is not in the schema.'
)
return f'Extra Table Failure: The data included a table named"{self.extra_table}" but it is not in the schema.'


@dataclass
Expand All @@ -60,7 +58,7 @@ def __str__(self):
"""
Method to get the string representation of the extra column failure.
"""
return f'Extra Column Failure: Table "{self.table}" Column' f' "{self.extra_column}" is not in the schema.'
return f'Extra Column Failure: Table "{self.table}" Column "{self.extra_column}" is not in the schema.'


@dataclass
Expand All @@ -73,8 +71,7 @@ class MissingColumnFailure(InternalValidationFailure):
def __str__(self):
"""Method to get the string representation of the missing column failure."""
return (
f'Missing Column Failure: Table "{self.table}" Column'
f' "{self.missing_column}" is missing from the schema.'
f'Missing Column Failure: Table "{self.table}" Column "{self.missing_column}" is missing from the schema.'
)


Expand All @@ -87,7 +84,7 @@ class NonUniqueFailure(InternalValidationFailure):

def __str__(self):
"""Method to get the string representation of the non-unique value failure."""
return f'Non Unique Failure: Table "{self.table}" column "{self.column}" should ' f"contain only unique values."
return f'Non Unique Failure: Table "{self.table}" column "{self.column}" should contain only unique values.'


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def parse_schema(schema: dict) -> dict[Any, Any]:
undefined_uniques = {unique for unique in uniques if unique not in columns}
assert isinstance(uniques, list), f'Uniques are not a list in table "{table}"'
assert not undefined_uniques, (
f'The following columns in table "{table}" are undefined but in ' f"uniques: {undefined_uniques}"
f'The following columns in table "{table}" are undefined but in uniques: {undefined_uniques}'
)

# Check foreign key definitions are valid
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ dev = [
"pytest-mock==3.14.0",
"pytest-playwright==0.6.2",
"requests-mock==1.12.1",
"ruff==0.8.4",
"ruff==0.9.2",
"types-beautifulsoup4==4.12.0.20241020",
"types-colorama==0.4.15.20240311",
"types-flask==1.1.6",
Expand Down
12 changes: 6 additions & 6 deletions tests/admin_tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def test_edit_instances(
if should_be_able_to_edit:
# We expect this error if the view was accessed "successfully" (ie user has admin group and the entity
# is configured to allow edits
assert "invalid input syntax for type uuid" in str(
ignore_id_error.excinfo
), "Looks like the test thinks you can edit the model, but you actually can't"
assert "invalid input syntax for type uuid" in str(ignore_id_error.excinfo), (
"Looks like the test thinks you can edit the model, but you actually can't"
)

@pytest.mark.parametrize("has_admin_role", [True, False])
@pytest.mark.parametrize("admin_view_name", models)
Expand Down Expand Up @@ -132,9 +132,9 @@ def test_delete_instances(
if should_be_able_to_delete:
# We expect this error if the view was accessed "successfully" (ie user has admin group and the entity
# is configured to allow edits
assert "invalid input syntax for type uuid" in str(
ignore_id_error.excinfo
), "Looks like the test thinks you can delete the model, but you actually can't"
assert "invalid input syntax for type uuid" in str(ignore_id_error.excinfo), (
"Looks like the test thinks you can delete the model, but you actually can't"
)


class TestAdminActionsAuthorization:
Expand Down
2 changes: 1 addition & 1 deletion tests/data_store_tests/controller_tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@ def test_sort_columns_exception(test_session):
with pytest.raises(ValueError) as e:
sort_output_dataframes(unsorted_place_df, "UnspecifiedSheet")
assert str(e.value) == (
"No table sort order defined for table extract: UnspecifiedSheet. Please add " "sheet to TABLE_SORT_ORDERS"
"No table sort order defined for table extract: UnspecifiedSheet. Please add sheet to TABLE_SORT_ORDERS"
)
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,13 @@ def test_project_progress_indexes(mock_ingest_full_extract):
def test_funding_questions_indexes(mock_ingest_full_extract):
"""Test that the indexes for Funding Questions are not lost in transformation."""
assert mock_ingest_full_extract["Funding Questions"]["Question"][15] == (
"Beyond these three funding types, have " "you received any payments for specific " "projects?"
"Beyond these three funding types, have you received any payments for specific projects?"
)
assert mock_ingest_full_extract["Funding Questions"]["Question"][17].iloc[0] == (
"Please confirm whether the amount " "utilised represents your entire " "allocation"
"Please confirm whether the amount utilised represents your entire allocation"
)
assert mock_ingest_full_extract["Funding Questions"]["Question"][20].iloc[0] == (
"Please explain in detail how the " "funding has, or will be, " "utilised"
"Please explain in detail how the funding has, or will be, utilised"
)


Expand Down Expand Up @@ -326,17 +326,17 @@ def test_outputs_indexes(mock_ingest_full_extract):
"""Test that the indexes for Outputs are not lost in transformation."""
assert mock_ingest_full_extract["Output_Data"]["Output"][24].iloc[0] == "# of temporary FT jobs supported"
assert mock_ingest_full_extract["Output_Data"]["Output"][25].iloc[0] == (
"# of full-time equivalent (FTE) permanent " "jobs " "created through the project"
"# of full-time equivalent (FTE) permanent jobs created through the project"
)
assert mock_ingest_full_extract["Output_Data"]["Output"][26].iloc[0] == (
"# of full-time equivalent (FTE) permanent " "jobs safeguarded through the project"
"# of full-time equivalent (FTE) permanent jobs safeguarded through the project"
)


def test_outcomes_indexes(mock_ingest_full_extract):
"""Test that the indexes for Outcomes are not lost in transformation."""
assert mock_ingest_full_extract["Outcome_Data"]["Outcome"][23].iloc[0] == (
"Patronage of the public transport system in " "the area of interest (for public transport " "schemes)"
"Patronage of the public transport system in the area of interest (for public transport schemes)"
)
assert mock_ingest_full_extract["Outcome_Data"]["Outcome"][43].iloc[0] == "test custom outcome"
assert mock_ingest_full_extract["Outcome_Data"]["Outcome"][24].iloc[0] == (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def test_ingest_pf_r1_auth_errors(test_client, pathfinders_round_1_file_success,
assert len(data["pre_transformation_errors"]) == 1

assert (
"You’re not authorised to submit for Bolton Council. You can only submit for Lewes" " District Council."
"You’re not authorised to submit for Bolton Council. You can only submit for Lewes District Council."
) in data["pre_transformation_errors"]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def test_ingest_with_r4_file_pre_transformation_failure(
assert data == {
"detail": "Workbook validation failed",
"pre_transformation_errors": [
"The selected file must be the Town Deals and Future High Streets Fund Reporting " "Template (v4.3).",
"The selected file must be the Town Deals and Future High Streets Fund Reporting Template (v4.3).",
"Cell B6 in the “start here” tab must say “1 April 2023 to 30 September 2023”. "
"Select this option from the dropdown list provided.",
"Cell E7 in the “project admin” must contain a fund type from the dropdown list "
Expand Down
Loading

0 comments on commit 846fcd7

Please sign in to comment.