Skip to content
Snippets Groups Projects
Commit 5c74efe8 authored by Karel van Klink's avatar Karel van Klink :smiley_cat: Committed by Neda Moeini
Browse files

Bump to python 3.12

parent 42877bcf
Branches
Tags
1 merge request!139Feature/add validation workflows
This commit is part of merge request !139. Comments created here will be created in the context of that merge request.
...@@ -364,7 +364,7 @@ def _evaluate_decision(decision: OPAResult, *, auto_error: bool, **context: dict ...@@ -364,7 +364,7 @@ def _evaluate_decision(decision: OPAResult, *, auto_error: bool, **context: dict
raise HTTPException( raise HTTPException(
status_code=HTTPStatus.FORBIDDEN, 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}",
) )
......
...@@ -307,14 +307,14 @@ def import_iptrunks(filepath: str = common_filepath_option) -> None: ...@@ -307,14 +307,14 @@ def import_iptrunks(filepath: str = common_filepath_option) -> None:
iptrunk_ipv4_network = ipv4_network_a iptrunk_ipv4_network = ipv4_network_a
else: else:
# Handle the case where IPv4 networks are different # 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 continue
# Check if IPv6 networks are the same # Check if IPv6 networks are the same
if ipv6_network_a == ipv6_network_b: if ipv6_network_a == ipv6_network_b:
iptrunk_ipv6_network = ipv6_network_a iptrunk_ipv6_network = ipv6_network_a
else: else:
# Handle the case where IPv6 networks are different # 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 continue
typer.echo( typer.echo(
...@@ -343,7 +343,7 @@ def import_iptrunks(filepath: str = common_filepath_option) -> None: ...@@ -343,7 +343,7 @@ def import_iptrunks(filepath: str = common_filepath_option) -> None:
) )
start_process("create_imported_iptrunk", [initial_data.model_dump()]) start_process("create_imported_iptrunk", [initial_data.model_dump()])
successfully_imported_data.append(trunk["id"]) 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: except ValidationError as e:
typer.echo(f"Validation error: {e}") typer.echo(f"Validation error: {e}")
......
...@@ -26,7 +26,7 @@ class LibreNMSClient: ...@@ -26,7 +26,7 @@ class LibreNMSClient:
self.snmp_config = config.SNMP self.snmp_config = config.SNMP
self.headers = { 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", "Accept": "application/json",
"Content-Type": "application/json", "Content-Type": "application/json",
"X-Auth-Token": token, "X-Auth-Token": token,
......
...@@ -47,7 +47,7 @@ def available_interfaces_choices(router_id: UUID, speed: str) -> Choice | None: ...@@ -47,7 +47,7 @@ def available_interfaces_choices(router_id: UUID, speed: str) -> Choice | None:
if get_router_vendor(router_id) != Vendor.NOKIA: if get_router_vendor(router_id) != Vendor.NOKIA:
return None return None
interfaces = { 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) 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] 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( ...@@ -77,7 +77,7 @@ def available_interfaces_choices_including_current_members(
], ],
) )
options = { 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] return Choice("ae member", zip(options.keys(), options.items(), strict=True)) # type: ignore[arg-type]
......
...@@ -31,6 +31,10 @@ extend-exclude = [ ...@@ -31,6 +31,10 @@ extend-exclude = [
"gso/migrations", "gso/migrations",
"docs", "docs",
] ]
target-version = "py312"
line-length = 120
[tool.ruff.lint]
ignore = [ ignore = [
"COM812", "COM812",
"D203", "D203",
...@@ -41,7 +45,6 @@ ignore = [ ...@@ -41,7 +45,6 @@ ignore = [
"PLR0904", "PLR0904",
"PLW1514", "PLW1514",
] ]
line-length = 120
select = [ select = [
"A", "A",
"ARG", "ARG",
...@@ -92,16 +95,16 @@ select = [ ...@@ -92,16 +95,16 @@ select = [
"W", "W",
"YTT" "YTT"
] ]
target-version = "py311"
[tool.ruff.flake8-tidy-imports] [tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all" ban-relative-imports = "all"
[tool.ruff.per-file-ignores] [tool.ruff.lint.per-file-ignores]
"test/*" = ["ARG001", "D", "S101", "PLR2004"] "gso/workflows/*" = ["PLR0917", "PLR0914"]
"test/*" = ["ARG001", "D", "S101", "PLR2004", "PLR0917", "PLR0914", "PLC0415", "PLC2701"]
"setup.py" = ["D100"] "setup.py" = ["D100"]
[tool.ruff.isort] [tool.ruff.lint.isort]
known-third-party = ["pydantic", "migrations"] known-third-party = ["pydantic", "migrations"]
known-first-party = ["test", "docs"] known-first-party = ["test", "docs"]
...@@ -113,6 +116,3 @@ filterwarnings = [ ...@@ -113,6 +116,3 @@ filterwarnings = [
"ignore", "ignore",
"default:::gso", "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
...@@ -143,7 +143,7 @@ def test_successful_iptrunk_creation_with_standard_lso_result( ...@@ -143,7 +143,7 @@ def test_successful_iptrunk_creation_with_standard_lso_result(
]) ])
assert subscription.status == "provisioning" assert subscription.status == "provisioning"
assert subscription.description == ( 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 assert mock_execute_playbook.call_count == 6
......
...@@ -59,7 +59,7 @@ def test_create_nokia_router_success( ...@@ -59,7 +59,7 @@ def test_create_nokia_router_success(
mock_v4 = faker.ipv4() mock_v4 = faker.ipv4()
mock_v6 = faker.ipv6() mock_v6 = faker.ipv6()
mock_fqdn = ( 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" f"{mock_site.site_country_code.lower()}.geant.net"
) )
mock_hostname_available.return_value = True mock_hostname_available.return_value = True
...@@ -143,7 +143,7 @@ def test_create_nokia_router_lso_failure( ...@@ -143,7 +143,7 @@ def test_create_nokia_router_lso_failure(
mock_v4_net = faker.ipv4(network=True) mock_v4_net = faker.ipv4(network=True)
mock_v6 = faker.ipv6() mock_v6 = faker.ipv6()
mock_fqdn = ( 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" f"{mock_site.site_country_code.lower()}.geant.net"
) )
mock_hostname_available.return_value = True mock_hostname_available.return_value = True
......
...@@ -35,7 +35,7 @@ def test_create_site(responses, faker): ...@@ -35,7 +35,7 @@ def test_create_site(responses, faker):
assert subscription.status == "active" assert subscription.status == "active"
assert ( assert (
subscription.description 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"]}"
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment