From fce46c6a9f366a4a710fd539a65ea68ff62e208a Mon Sep 17 00:00:00 2001 From: Laurent LAPORTE Date: Thu, 28 Mar 2024 17:27:37 +0100 Subject: [PATCH] chore: correct style in source code --- tests/integration/studies_blueprint/test_comments.py | 2 +- tests/integration/studies_blueprint/test_synthesis.py | 2 +- tests/integration/test_integration_watcher.py | 10 ++-------- tests/launcher/test_web.py | 2 +- tests/login/test_model.py | 3 --- tests/login/test_repository.py | 2 +- tests/storage/business/test_variant_study_service.py | 2 +- tests/storage/repository/filesystem/test_lazy_node.py | 2 +- .../storage/variantstudy/test_snapshot_generator.py | 1 - .../storage/variantstudy/test_variant_study_service.py | 1 - .../variantstudy/model/command/test_create_cluster.py | 6 +++--- tests/variantstudy/model/command/test_create_link.py | 4 ++-- .../model/command/test_create_renewables_cluster.py | 2 +- 13 files changed, 14 insertions(+), 25 deletions(-) diff --git a/tests/integration/studies_blueprint/test_comments.py b/tests/integration/studies_blueprint/test_comments.py index b282ed8781..378be0aed5 100644 --- a/tests/integration/studies_blueprint/test_comments.py +++ b/tests/integration/studies_blueprint/test_comments.py @@ -88,7 +88,7 @@ def test_variant_study( res = client.post( f"/v1/studies/{base_study_id}/variants", headers={"Authorization": f"Bearer {user_access_token}"}, - params={"name": f"Variant XYZ"}, + params={"name": "Variant XYZ"}, ) assert res.status_code == 200, res.json() # should be CREATED variant_id = res.json() diff --git a/tests/integration/studies_blueprint/test_synthesis.py b/tests/integration/studies_blueprint/test_synthesis.py index 059fba2aa7..1f10fa2989 100644 --- a/tests/integration/studies_blueprint/test_synthesis.py +++ b/tests/integration/studies_blueprint/test_synthesis.py @@ -84,7 +84,7 @@ def test_variant_study( res = client.post( f"/v1/studies/{base_study_id}/variants", headers={"Authorization": f"Bearer {user_access_token}"}, - params={"name": f"Variant XYZ"}, + params={"name": "Variant XYZ"}, ) assert res.status_code == 200, res.json() # should be CREATED variant_id = res.json() diff --git a/tests/integration/test_integration_watcher.py b/tests/integration/test_integration_watcher.py index 0ac0e3afd0..e151a3ade3 100644 --- a/tests/integration/test_integration_watcher.py +++ b/tests/integration/test_integration_watcher.py @@ -8,11 +8,5 @@ def test_integration_xpansion(app: FastAPI, tmp_path: str): admin_credentials = res.json() headers = {"Authorization": f'Bearer {admin_credentials["access_token"]}'} - client.post( - f"/v1/watcher/_scan", - headers=headers, - ) - client.post( - f"/v1/watcher/_scan?path=/tmp", - headers=headers, - ) + client.post("/v1/watcher/_scan", headers=headers) + client.post("/v1/watcher/_scan?path=/tmp", headers=headers) diff --git a/tests/launcher/test_web.py b/tests/launcher/test_web.py index 99799abbde..e0800cf019 100644 --- a/tests/launcher/test_web.py +++ b/tests/launcher/test_web.py @@ -100,7 +100,7 @@ def test_jobs() -> None: assert res.status_code == 200 assert [JobResultDTO.parse_obj(j) for j in res.json()] == [result.to_dto()] - res = client.get(f"/v1/launcher/jobs") + res = client.get("/v1/launcher/jobs") assert res.status_code == 200 assert [JobResultDTO.parse_obj(j) for j in res.json()] == [result.to_dto()] service.get_jobs.assert_has_calls( diff --git a/tests/login/test_model.py b/tests/login/test_model.py index 2dee1d994e..e1ef0bc928 100644 --- a/tests/login/test_model.py +++ b/tests/login/test_model.py @@ -1,7 +1,4 @@ -import contextlib - from sqlalchemy.engine.base import Engine # type: ignore -from sqlalchemy.exc import IntegrityError # type: ignore from sqlalchemy.orm import sessionmaker # type: ignore from antarest.login.model import ( diff --git a/tests/login/test_repository.py b/tests/login/test_repository.py index 60bdbc0dbf..5ab7406dc4 100644 --- a/tests/login/test_repository.py +++ b/tests/login/test_repository.py @@ -1,5 +1,5 @@ import pytest -from sqlalchemy.orm import Session, scoped_session, sessionmaker # type: ignore +from sqlalchemy.orm import Session # type: ignore from antarest.login.model import Bot, Group, Password, Role, RoleType, User, UserLdap from antarest.login.repository import BotRepository, GroupRepository, RoleRepository, UserLdapRepository, UserRepository diff --git a/tests/storage/business/test_variant_study_service.py b/tests/storage/business/test_variant_study_service.py index 8c6ac3602c..7c6e00f99c 100644 --- a/tests/storage/business/test_variant_study_service.py +++ b/tests/storage/business/test_variant_study_service.py @@ -92,7 +92,7 @@ def task_status(*args): yield t study_service.task_service.status_task.side_effect = task_status() - with pytest.raises(VariantGenerationError, match=f"Error while generating study2.py"): + with pytest.raises(VariantGenerationError, match="Error while generating study2.py"): study_service.get(metadata=metadata, url=sub_route, depth=2) study_service.task_service.await_task.assert_called() diff --git a/tests/storage/repository/filesystem/test_lazy_node.py b/tests/storage/repository/filesystem/test_lazy_node.py index e0e8e91e5a..f899d32fa3 100644 --- a/tests/storage/repository/filesystem/test_lazy_node.py +++ b/tests/storage/repository/filesystem/test_lazy_node.py @@ -112,7 +112,7 @@ def test_save_uri(tmp_path: Path): context = ContextServer(matrix=Mock(), resolver=resolver) node = MockLazyNode(context=context, config=config) - uri = f"matrix://id" + uri = "matrix://id" node.save(uri) assert (file.parent / f"{file.name}.link").read_text() == uri assert not file.exists() diff --git a/tests/study/storage/variantstudy/test_snapshot_generator.py b/tests/study/storage/variantstudy/test_snapshot_generator.py index 5e90b6ee06..2365049432 100644 --- a/tests/study/storage/variantstudy/test_snapshot_generator.py +++ b/tests/study/storage/variantstudy/test_snapshot_generator.py @@ -10,7 +10,6 @@ import numpy as np import pytest -from sqlalchemy import event # type: ignore from antarest.core.exceptions import VariantGenerationError from antarest.core.interfaces.cache import CacheConstants diff --git a/tests/study/storage/variantstudy/test_variant_study_service.py b/tests/study/storage/variantstudy/test_variant_study_service.py index 25317a9589..9dce83e735 100644 --- a/tests/study/storage/variantstudy/test_variant_study_service.py +++ b/tests/study/storage/variantstudy/test_variant_study_service.py @@ -5,7 +5,6 @@ import numpy as np import pytest -from sqlalchemy import create_engine # type: ignore from antarest.core.model import PublicMode from antarest.core.requests import RequestParameters diff --git a/tests/variantstudy/model/command/test_create_cluster.py b/tests/variantstudy/model/command/test_create_cluster.py index 4fdeb3c488..6554bbe6c2 100644 --- a/tests/variantstudy/model/command/test_create_cluster.py +++ b/tests/variantstudy/model/command/test_create_cluster.py @@ -247,17 +247,17 @@ def test_create_diff(command_context: CommandContext): assert base.create_diff(other_match) == [ ReplaceMatrix( - target=f"input/thermal/prepro/foo/foo/data", + target="input/thermal/prepro/foo/foo/data", matrix=prepro_b, command_context=command_context, ), ReplaceMatrix( - target=f"input/thermal/prepro/foo/foo/modulation", + target="input/thermal/prepro/foo/foo/modulation", matrix=modulation_b, command_context=command_context, ), UpdateConfig( - target=f"input/thermal/clusters/foo/list/foo", + target="input/thermal/clusters/foo/list/foo", data={"nominalcapacity": "2400"}, command_context=command_context, ), diff --git a/tests/variantstudy/model/command/test_create_link.py b/tests/variantstudy/model/command/test_create_link.py index 413e97038d..b2e8715ae3 100644 --- a/tests/variantstudy/model/command/test_create_link.py +++ b/tests/variantstudy/model/command/test_create_link.py @@ -254,12 +254,12 @@ def test_create_diff(command_context: CommandContext): assert base.create_diff(other_match) == [ UpdateConfig( - target=f"input/links/bar/properties/foo", + target="input/links/bar/properties/foo", data=CreateLink.generate_link_properties({"hurdles-cost": "true"}), command_context=command_context, ), ReplaceMatrix( - target=f"@links_series/bar/foo", + target="@links_series/bar/foo", matrix=series_b, command_context=command_context, ), diff --git a/tests/variantstudy/model/command/test_create_renewables_cluster.py b/tests/variantstudy/model/command/test_create_renewables_cluster.py index fc6ac91afe..ecec2fd882 100644 --- a/tests/variantstudy/model/command/test_create_renewables_cluster.py +++ b/tests/variantstudy/model/command/test_create_renewables_cluster.py @@ -190,7 +190,7 @@ def test_create_diff(command_context: CommandContext): ) assert base.create_diff(other_match) == [ UpdateConfig( - target=f"input/renewables/clusters/foo/list/foo", + target="input/renewables/clusters/foo/list/foo", data={"a": "b"}, command_context=command_context, ),