From 5c74efe828b33ba6d7c3215a1bb2acf13088aff7 Mon Sep 17 00:00:00 2001 From: Karel van Klink <karel.vanklink@geant.org> Date: Tue, 30 Apr 2024 10:59:06 +0200 Subject: [PATCH] Bump to python 3.12 --- gso/auth/oidc_policy_helper.py | 2 +- gso/cli/imports.py | 6 +++--- gso/services/librenms_client.py | 2 +- gso/utils/helpers.py | 4 ++-- pyproject.toml | 18 +++++++++--------- test/workflows/iptrunk/test_create_iptrunk.py | 2 +- test/workflows/router/test_create_router.py | 4 ++-- test/workflows/site/test_create_site.py | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/gso/auth/oidc_policy_helper.py b/gso/auth/oidc_policy_helper.py index eca66512..51b6bf01 100644 --- a/gso/auth/oidc_policy_helper.py +++ b/gso/auth/oidc_policy_helper.py @@ -364,7 +364,7 @@ def _evaluate_decision(decision: OPAResult, *, auto_error: bool, **context: dict raise HTTPException( status_code=HTTPStatus.FORBIDDEN, - detail=f"User is not allowed to access resource: {context.get('resource')} Decision was taken with id: {did}", + detail=f"User is not allowed to access resource: {context.get("resource")} Decision was taken with id: {did}", ) diff --git a/gso/cli/imports.py b/gso/cli/imports.py index 0a41ac74..3a6dcf1c 100644 --- a/gso/cli/imports.py +++ b/gso/cli/imports.py @@ -307,14 +307,14 @@ def import_iptrunks(filepath: str = common_filepath_option) -> None: iptrunk_ipv4_network = ipv4_network_a else: # Handle the case where IPv4 networks are different - typer.echo(f"Error: IPv4 networks are different for trunk {trunk['id']}.") + typer.echo(f"Error: IPv4 networks are different for trunk {trunk["id"]}.") continue # Check if IPv6 networks are the same if ipv6_network_a == ipv6_network_b: iptrunk_ipv6_network = ipv6_network_a else: # Handle the case where IPv6 networks are different - typer.echo(f"Error: IPv6 networks are different for trunk {trunk['id']}.") + typer.echo(f"Error: IPv6 networks are different for trunk {trunk["id"]}.") continue typer.echo( @@ -343,7 +343,7 @@ def import_iptrunks(filepath: str = common_filepath_option) -> None: ) start_process("create_imported_iptrunk", [initial_data.model_dump()]) successfully_imported_data.append(trunk["id"]) - typer.echo(f"Successfully imported IP Trunk: {trunk['id']}") + typer.echo(f"Successfully imported IP Trunk: {trunk["id"]}") except ValidationError as e: typer.echo(f"Validation error: {e}") diff --git a/gso/services/librenms_client.py b/gso/services/librenms_client.py index e4564b83..749974f1 100644 --- a/gso/services/librenms_client.py +++ b/gso/services/librenms_client.py @@ -26,7 +26,7 @@ class LibreNMSClient: self.snmp_config = config.SNMP self.headers = { - "User-Agent": f"geant-service-orchestrator/{metadata.version('geant-service-orchestrator')}", + "User-Agent": f"geant-service-orchestrator/{metadata.version("geant-service-orchestrator")}", "Accept": "application/json", "Content-Type": "application/json", "X-Auth-Token": token, diff --git a/gso/utils/helpers.py b/gso/utils/helpers.py index d27e7c6d..edd01009 100644 --- a/gso/utils/helpers.py +++ b/gso/utils/helpers.py @@ -47,7 +47,7 @@ def available_interfaces_choices(router_id: UUID, speed: str) -> Choice | None: if get_router_vendor(router_id) != Vendor.NOKIA: return None interfaces = { - interface["name"]: f"{interface['name']} {interface['description']}" + interface["name"]: f"{interface["name"]} {interface["description"]}" for interface in NetboxClient().get_available_interfaces(router_id, speed) } return Choice("ae member", zip(interfaces.keys(), interfaces.items(), strict=True)) # type: ignore[arg-type] @@ -77,7 +77,7 @@ def available_interfaces_choices_including_current_members( ], ) options = { - interface["name"]: f"{interface['name']} {interface['description']}" for interface in available_interfaces + interface["name"]: f"{interface["name"]} {interface["description"]}" for interface in available_interfaces } return Choice("ae member", zip(options.keys(), options.items(), strict=True)) # type: ignore[arg-type] diff --git a/pyproject.toml b/pyproject.toml index 376371b7..e9979242 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,10 @@ extend-exclude = [ "gso/migrations", "docs", ] +target-version = "py312" +line-length = 120 + +[tool.ruff.lint] ignore = [ "COM812", "D203", @@ -41,7 +45,6 @@ ignore = [ "PLR0904", "PLW1514", ] -line-length = 120 select = [ "A", "ARG", @@ -92,16 +95,16 @@ select = [ "W", "YTT" ] -target-version = "py311" -[tool.ruff.flake8-tidy-imports] +[tool.ruff.lint.flake8-tidy-imports] ban-relative-imports = "all" -[tool.ruff.per-file-ignores] -"test/*" = ["ARG001", "D", "S101", "PLR2004"] +[tool.ruff.lint.per-file-ignores] +"gso/workflows/*" = ["PLR0917", "PLR0914"] +"test/*" = ["ARG001", "D", "S101", "PLR2004", "PLR0917", "PLR0914", "PLC0415", "PLC2701"] "setup.py" = ["D100"] -[tool.ruff.isort] +[tool.ruff.lint.isort] known-third-party = ["pydantic", "migrations"] known-first-party = ["test", "docs"] @@ -113,6 +116,3 @@ filterwarnings = [ "ignore", "default:::gso", ] -[tool.ruff.lint.per-file-ignores] -"test/*" = ["PLR0917", "S101", "D104", "D105", "D103", "D100", "ARG001", "D102", "PLR2004", "D101", "D106", "D107", "PLR0914", "PLC0415", "PLC2701"] -"gso/workflows/*" = ["PLR0917", "PLR0914"] \ No newline at end of file diff --git a/test/workflows/iptrunk/test_create_iptrunk.py b/test/workflows/iptrunk/test_create_iptrunk.py index ea82a5bf..de15a712 100644 --- a/test/workflows/iptrunk/test_create_iptrunk.py +++ b/test/workflows/iptrunk/test_create_iptrunk.py @@ -143,7 +143,7 @@ def test_successful_iptrunk_creation_with_standard_lso_result( ]) assert subscription.status == "provisioning" assert subscription.description == ( - f"IP trunk {sorted_sides[0]} {sorted_sides[1]}, geant_s_sid:{input_form_wizard_data[0]['geant_s_sid']}" + f"IP trunk {sorted_sides[0]} {sorted_sides[1]}, geant_s_sid:{input_form_wizard_data[0]["geant_s_sid"]}" ) assert mock_execute_playbook.call_count == 6 diff --git a/test/workflows/router/test_create_router.py b/test/workflows/router/test_create_router.py index 5a96dbc7..e6cc65ba 100644 --- a/test/workflows/router/test_create_router.py +++ b/test/workflows/router/test_create_router.py @@ -59,7 +59,7 @@ def test_create_nokia_router_success( mock_v4 = faker.ipv4() mock_v6 = faker.ipv6() mock_fqdn = ( - f"{router_creation_input_form_data['hostname']}.{mock_site.site_name.lower()}." + f"{router_creation_input_form_data["hostname"]}.{mock_site.site_name.lower()}." f"{mock_site.site_country_code.lower()}.geant.net" ) mock_hostname_available.return_value = True @@ -143,7 +143,7 @@ def test_create_nokia_router_lso_failure( mock_v4_net = faker.ipv4(network=True) mock_v6 = faker.ipv6() mock_fqdn = ( - f"{router_creation_input_form_data['hostname']}.{mock_site.site_name.lower()}." + f"{router_creation_input_form_data["hostname"]}.{mock_site.site_name.lower()}." f"{mock_site.site_country_code.lower()}.geant.net" ) mock_hostname_available.return_value = True diff --git a/test/workflows/site/test_create_site.py b/test/workflows/site/test_create_site.py index f6c196da..7642debe 100644 --- a/test/workflows/site/test_create_site.py +++ b/test/workflows/site/test_create_site.py @@ -35,7 +35,7 @@ def test_create_site(responses, faker): assert subscription.status == "active" assert ( subscription.description - == f"Site in {initial_site_data[1]['site_city']}, {initial_site_data[1]['site_country']}" + == f"Site in {initial_site_data[1]["site_city"]}, {initial_site_data[1]["site_country"]}" ) -- GitLab