From 9afcbcf2c721ed5951daf10bda7b399e569c9ae8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 25 Jan 2025 21:04:43 +0000 Subject: [PATCH] chore(deps): update pre-commit hook astral-sh/ruff-pre-commit to v0.9.2 (#2087) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: anders-albert --- .pre-commit-config.yaml | 2 +- .../client/data_classes/data_modeling/instances.py | 3 +-- cognite/client/data_classes/sequences.py | 2 +- cognite/client/data_classes/workflows.py | 2 +- cognite/client/utils/_text.py | 2 +- scripts/custom_checks/docstr_examples.py | 2 +- .../test_api/test_datapoint_subscriptions.py | 12 ++++++------ tests/tests_integration/test_api/test_diagrams.py | 2 +- .../test_data_classes/test_data_models/test_ids.py | 12 ++++++------ 9 files changed, 19 insertions(+), 20 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 576955e8c7..fa61f4595b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ --- repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.6 + rev: v0.9.2 hooks: - id: ruff args: diff --git a/cognite/client/data_classes/data_modeling/instances.py b/cognite/client/data_classes/data_modeling/instances.py index 7ded525062..52e5d57ea4 100644 --- a/cognite/client/data_classes/data_modeling/instances.py +++ b/cognite/client/data_classes/data_modeling/instances.py @@ -233,8 +233,7 @@ def load( view_tuple = tuple(view_id_str.split("/", 1)) if len(view_tuple) != 2: warnings.warn( - f"Unknown type of view id: {view_id_str}, expected format /. " - "Skipping...", + f"Unknown type of view id: {view_id_str}, expected format /. Skipping...", stacklevel=2, ) continue diff --git a/cognite/client/data_classes/sequences.py b/cognite/client/data_classes/sequences.py index 777d54cd58..837e039152 100644 --- a/cognite/client/data_classes/sequences.py +++ b/cognite/client/data_classes/sequences.py @@ -663,7 +663,7 @@ def __init__( col_length = len(columns) if wrong_length := [r for r in rows if len(r.values) != col_length]: raise ValueError( - f"Rows { [r.row_number for r in wrong_length] } have wrong number of values, expected {col_length}" + f"Rows {[r.row_number for r in wrong_length]} have wrong number of values, expected {col_length}" ) self.rows = rows self.columns: SequenceColumnList = columns diff --git a/cognite/client/data_classes/workflows.py b/cognite/client/data_classes/workflows.py index 918762abcb..d8a744728a 100644 --- a/cognite/client/data_classes/workflows.py +++ b/cognite/client/data_classes/workflows.py @@ -292,7 +292,7 @@ def dump(self, camel_case: bool = True) -> dict[str, Any]: if self.run_time: simulation["runTime" if camel_case else "run_time"] = self.run_time if self.inputs: - simulation["inputs" if camel_case else "inputs"] = [item.dump(camel_case) for item in self.inputs] + simulation["inputs"] = [item.dump(camel_case) for item in self.inputs] return {"simulation": simulation} diff --git a/cognite/client/utils/_text.py b/cognite/client/utils/_text.py index 2166be7b44..4304fd281c 100644 --- a/cognite/client/utils/_text.py +++ b/cognite/client/utils/_text.py @@ -89,4 +89,4 @@ def shorten(obj: Any, width: int = 20, placeholder: str = "...") -> str: s = obj if isinstance(obj, str) else repr(obj) if len(s) <= width: return s - return f"{s[:width-n]}{placeholder}" + return f"{s[: width - n]}{placeholder}" diff --git a/scripts/custom_checks/docstr_examples.py b/scripts/custom_checks/docstr_examples.py index 3b10ed4ebe..b0dbe642f1 100644 --- a/scripts/custom_checks/docstr_examples.py +++ b/scripts/custom_checks/docstr_examples.py @@ -63,7 +63,7 @@ def parse_example_section(lines, ex_idx) -> tuple[bool, set[int]]: def fix_single_file(path: Path) -> str | None: was_fixed = [] dotted = path_to_importable(path) - full_text = path.read_text() + full_text = path.read_text(encoding="utf-8") module = importlib.import_module(dotted) for cls_name, cls in get_valid_members(module, dotted): for method_name, ex_idx, docstr, lines in get_info_on_valid_methods(cls, full_text): diff --git a/tests/tests_integration/test_api/test_datapoint_subscriptions.py b/tests/tests_integration/test_api/test_datapoint_subscriptions.py index ccd909ac4f..7c1f765ce9 100644 --- a/tests/tests_integration/test_api/test_datapoint_subscriptions.py +++ b/tests/tests_integration/test_api/test_datapoint_subscriptions.py @@ -248,14 +248,14 @@ def test_iterate_data_subscription_initial_call( ) batch = next(subscription_changes) - assert ( - len(batch.subscription_changes.added) > 0 - ), "The subscription used for testing datapoint subscriptions must have at least one time series" + assert len(batch.subscription_changes.added) > 0, ( + "The subscription used for testing datapoint subscriptions must have at least one time series" + ) batch = next(subscription_changes) - assert ( - len(batch.subscription_changes.added) == 0 - ), "There should be no more timeseries in the subsequent batches" + assert len(batch.subscription_changes.added) == 0, ( + "There should be no more timeseries in the subsequent batches" + ) def test_iterate_data_subscription_changed_time_series( self, cognite_client: CogniteClient, time_series_external_ids: list[str] diff --git a/tests/tests_integration/test_api/test_diagrams.py b/tests/tests_integration/test_api/test_diagrams.py index 7c04c18e27..4e661d0138 100644 --- a/tests/tests_integration/test_api/test_diagrams.py +++ b/tests/tests_integration/test_api/test_diagrams.py @@ -12,7 +12,7 @@ ) from cognite.client.data_classes.data_modeling import NodeApply, NodeId, NodeOrEdgeData, Space, SpaceApply, ViewId -PNID_FILE_EXTERNAL_ID = "mypnid.pdf" "" +PNID_FILE_EXTERNAL_ID = "mypnid.pdf" DIAGRAM_SPACE = "diagram_space" CDM_SPACE = "cdf_cdm" diff --git a/tests/tests_unit/test_data_classes/test_data_models/test_ids.py b/tests/tests_unit/test_data_classes/test_data_models/test_ids.py index bc152df965..e4a50713da 100644 --- a/tests/tests_unit/test_data_classes/test_data_models/test_ids.py +++ b/tests/tests_unit/test_data_classes/test_data_models/test_ids.py @@ -59,9 +59,9 @@ def test_load( identifier = _load_identifier(ids, id_type) assert identifier.as_dicts() == expected_dict - assert ( - identifier.is_singleton() == expected_is_singleton - ), f"Expected {expected_is_singleton} but got {identifier.is_singleton()}" + assert identifier.is_singleton() == expected_is_singleton, ( + f"Expected {expected_is_singleton} but got {identifier.is_singleton()}" + ) @pytest.mark.parametrize( "ids, expected_dict, expected_is_singleton", @@ -76,6 +76,6 @@ def test_load_space_identifier( identifier = _load_space_identifier(ids) assert identifier.as_dicts() == expected_dict - assert ( - identifier.is_singleton() == expected_is_singleton - ), f"Expected {expected_is_singleton} but got {identifier.is_singleton()}" + assert identifier.is_singleton() == expected_is_singleton, ( + f"Expected {expected_is_singleton} but got {identifier.is_singleton()}" + )