diff --git a/data_safe_haven/administration/users/active_directory_users.py b/data_safe_haven/administration/users/active_directory_users.py index 8a60fe9b40..759175939b 100644 --- a/data_safe_haven/administration/users/active_directory_users.py +++ b/data_safe_haven/administration/users/active_directory_users.py @@ -1,4 +1,5 @@ """Interact with users in an Azure Active Directory""" + import pathlib from collections.abc import Sequence from typing import Any diff --git a/data_safe_haven/administration/users/azure_ad_users.py b/data_safe_haven/administration/users/azure_ad_users.py index 33141e9923..29a7586e95 100644 --- a/data_safe_haven/administration/users/azure_ad_users.py +++ b/data_safe_haven/administration/users/azure_ad_users.py @@ -1,4 +1,5 @@ """Interact with users in an Azure Active Directory""" + from collections.abc import Sequence from typing import Any diff --git a/data_safe_haven/cli.py b/data_safe_haven/cli.py index 4242953aa1..ed6aa0a9c4 100644 --- a/data_safe_haven/cli.py +++ b/data_safe_haven/cli.py @@ -1,4 +1,5 @@ """Command line entrypoint for Data Safe Haven application""" + import pathlib from typing import Annotated, Optional diff --git a/data_safe_haven/commands/admin.py b/data_safe_haven/commands/admin.py index afbe0bb1e9..cb53828b21 100644 --- a/data_safe_haven/commands/admin.py +++ b/data_safe_haven/commands/admin.py @@ -1,4 +1,5 @@ """Command-line application for performing administrative tasks""" + import pathlib from typing import Annotated diff --git a/data_safe_haven/commands/admin_add_users.py b/data_safe_haven/commands/admin_add_users.py index bf8b7ab446..a041d7dc78 100644 --- a/data_safe_haven/commands/admin_add_users.py +++ b/data_safe_haven/commands/admin_add_users.py @@ -1,4 +1,5 @@ """Add users to a deployed Data Safe Haven""" + import pathlib from data_safe_haven.administration.users import UserHandler diff --git a/data_safe_haven/commands/admin_list_users.py b/data_safe_haven/commands/admin_list_users.py index 25bf5f11ce..5d396af47d 100644 --- a/data_safe_haven/commands/admin_list_users.py +++ b/data_safe_haven/commands/admin_list_users.py @@ -1,4 +1,5 @@ """List users from a deployed Data Safe Haven""" + from data_safe_haven.administration.users import UserHandler from data_safe_haven.config import Config, ContextSettings from data_safe_haven.exceptions import DataSafeHavenError diff --git a/data_safe_haven/commands/admin_register_users.py b/data_safe_haven/commands/admin_register_users.py index 10c5451309..7ceb6e169c 100644 --- a/data_safe_haven/commands/admin_register_users.py +++ b/data_safe_haven/commands/admin_register_users.py @@ -1,4 +1,5 @@ """Register existing users with a deployed SRE""" + from data_safe_haven.administration.users import UserHandler from data_safe_haven.config import Config, ContextSettings from data_safe_haven.exceptions import DataSafeHavenError diff --git a/data_safe_haven/commands/admin_remove_users.py b/data_safe_haven/commands/admin_remove_users.py index 8718e891dd..36c5ea4763 100644 --- a/data_safe_haven/commands/admin_remove_users.py +++ b/data_safe_haven/commands/admin_remove_users.py @@ -1,4 +1,5 @@ """Remove existing users from a deployed Data Safe Haven""" + from data_safe_haven.administration.users import UserHandler from data_safe_haven.config import Config, ContextSettings from data_safe_haven.exceptions import DataSafeHavenError diff --git a/data_safe_haven/commands/admin_unregister_users.py b/data_safe_haven/commands/admin_unregister_users.py index e6a85445fa..64f7fec3dd 100644 --- a/data_safe_haven/commands/admin_unregister_users.py +++ b/data_safe_haven/commands/admin_unregister_users.py @@ -1,4 +1,5 @@ """Unregister existing users from a deployed SRE""" + from data_safe_haven.administration.users import UserHandler from data_safe_haven.config import Config, ContextSettings from data_safe_haven.exceptions import DataSafeHavenError diff --git a/data_safe_haven/commands/config.py b/data_safe_haven/commands/config.py index 9873cdf6ee..79c6bc3a79 100644 --- a/data_safe_haven/commands/config.py +++ b/data_safe_haven/commands/config.py @@ -1,4 +1,5 @@ """Command group and entrypoints for managing DSH configuration""" + from pathlib import Path from typing import Annotated, Optional diff --git a/data_safe_haven/commands/context.py b/data_safe_haven/commands/context.py index 5774670465..3addf2ae1e 100644 --- a/data_safe_haven/commands/context.py +++ b/data_safe_haven/commands/context.py @@ -1,4 +1,5 @@ """Command group and entrypoints for managing a DSH context""" + from typing import Annotated, Optional import typer diff --git a/data_safe_haven/commands/deploy.py b/data_safe_haven/commands/deploy.py index d15189a5ba..fb769d7eb9 100644 --- a/data_safe_haven/commands/deploy.py +++ b/data_safe_haven/commands/deploy.py @@ -1,4 +1,5 @@ """Command-line application for deploying a Data Safe Haven component, delegating the details to a subcommand""" + from typing import Annotated, Optional import typer diff --git a/data_safe_haven/commands/teardown.py b/data_safe_haven/commands/teardown.py index 24303c8c29..2adb788424 100644 --- a/data_safe_haven/commands/teardown.py +++ b/data_safe_haven/commands/teardown.py @@ -1,4 +1,5 @@ """Command-line application for tearing down a Data Safe Haven component, delegating the details to a subcommand""" + from typing import Annotated import typer diff --git a/data_safe_haven/config/config.py b/data_safe_haven/config/config.py index 661288cf4e..4b7d36353a 100644 --- a/data_safe_haven/config/config.py +++ b/data_safe_haven/config/config.py @@ -1,4 +1,5 @@ """Configuration file backed by blob storage""" + from __future__ import annotations from pathlib import Path diff --git a/data_safe_haven/config/context_settings.py b/data_safe_haven/config/context_settings.py index 1c48165dbc..50071859a9 100644 --- a/data_safe_haven/config/context_settings.py +++ b/data_safe_haven/config/context_settings.py @@ -1,4 +1,5 @@ """Load global and local settings from dotfiles""" + # For postponed evaluation of annotations https://peps.python.org/pep-0563 from __future__ import ( annotations, diff --git a/data_safe_haven/external/api/azure_api.py b/data_safe_haven/external/api/azure_api.py index fc36d9469b..7197d04298 100644 --- a/data_safe_haven/external/api/azure_api.py +++ b/data_safe_haven/external/api/azure_api.py @@ -1,4 +1,5 @@ """Interface to the Azure Python SDK""" + import time from collections.abc import Sequence from contextlib import suppress @@ -425,10 +426,10 @@ def ensure_keyvault_self_signed_certificate( enhanced_key_usage=["1.3.6.1.5.5.7.3.1", "1.3.6.1.5.5.7.3.2"], validity_in_months=12, ) - poller: LROPoller[ - KeyVaultCertificate - ] = certificate_client.begin_create_certificate( - certificate_name=certificate_name, policy=policy + poller: LROPoller[KeyVaultCertificate] = ( + certificate_client.begin_create_certificate( + certificate_name=certificate_name, policy=policy + ) ) certificate = poller.result() self.logger.info( diff --git a/data_safe_haven/external/api/azure_cli.py b/data_safe_haven/external/api/azure_cli.py index 2848b22fba..1f9cf3976d 100644 --- a/data_safe_haven/external/api/azure_cli.py +++ b/data_safe_haven/external/api/azure_cli.py @@ -1,4 +1,5 @@ """Interface to the Azure CLI""" + import json import subprocess from dataclasses import dataclass diff --git a/data_safe_haven/external/api/graph_api.py b/data_safe_haven/external/api/graph_api.py index d1eeddbd64..8edfa063a1 100644 --- a/data_safe_haven/external/api/graph_api.py +++ b/data_safe_haven/external/api/graph_api.py @@ -1,4 +1,5 @@ """Interface to the Microsoft Graph API""" + import datetime import pathlib import time diff --git a/data_safe_haven/external/interface/azure_authenticator.py b/data_safe_haven/external/interface/azure_authenticator.py index c6f32d91e0..838833cb69 100644 --- a/data_safe_haven/external/interface/azure_authenticator.py +++ b/data_safe_haven/external/interface/azure_authenticator.py @@ -1,4 +1,5 @@ """Standalone utility class for anything that needs to authenticate against Azure""" + from typing import cast from azure.core.exceptions import ClientAuthenticationError diff --git a/data_safe_haven/external/interface/azure_fileshare.py b/data_safe_haven/external/interface/azure_fileshare.py index 91da5c6bd2..d846dbbac4 100644 --- a/data_safe_haven/external/interface/azure_fileshare.py +++ b/data_safe_haven/external/interface/azure_fileshare.py @@ -1,4 +1,5 @@ """Helper class for Azure fileshares""" + from contextlib import suppress from azure.core.exceptions import ResourceNotFoundError diff --git a/data_safe_haven/infrastructure/common/ip_ranges.py b/data_safe_haven/infrastructure/common/ip_ranges.py index bbdf8ae711..e636531295 100644 --- a/data_safe_haven/infrastructure/common/ip_ranges.py +++ b/data_safe_haven/infrastructure/common/ip_ranges.py @@ -1,4 +1,5 @@ """Calculate SRE IP address ranges for a given SRE index""" + from data_safe_haven.external import AzureIPv4Range diff --git a/data_safe_haven/infrastructure/common/transformations.py b/data_safe_haven/infrastructure/common/transformations.py index 9449f91328..df2ec167bf 100644 --- a/data_safe_haven/infrastructure/common/transformations.py +++ b/data_safe_haven/infrastructure/common/transformations.py @@ -1,4 +1,5 @@ """Common transformations needed when manipulating Pulumi resources""" + from pulumi import Output from pulumi_azure_native import containerinstance, network, resources @@ -42,9 +43,9 @@ def get_ip_address_from_container_group( ) -> Output[str]: """Get the IP address of a container group""" return container_group.ip_address.apply( - lambda ip_address: (ip_address.ip if ip_address.ip else "") - if ip_address - else "" + lambda ip_address: ( + (ip_address.ip if ip_address.ip else "") if ip_address else "" + ) ) @@ -54,11 +55,17 @@ def get_ip_addresses_from_private_endpoint( """Get a list of IP addresses from a private endpoint""" if isinstance(endpoint.custom_dns_configs, Output): return endpoint.custom_dns_configs.apply( - lambda cfgs: sum( - [list(cfg.ip_addresses) if cfg.ip_addresses else [] for cfg in cfgs], [] + lambda cfgs: ( + sum( + [ + list(cfg.ip_addresses) if cfg.ip_addresses else [] + for cfg in cfgs + ], + [], + ) + if cfgs + else [] ) - if cfgs - else [] ) msg = f"Private endpoint '{endpoint.name}' has no IP addresses." raise DataSafeHavenPulumiError(msg) diff --git a/data_safe_haven/infrastructure/components/composite/automation_dsc_node.py b/data_safe_haven/infrastructure/components/composite/automation_dsc_node.py index fc197936af..19c9e5026c 100644 --- a/data_safe_haven/infrastructure/components/composite/automation_dsc_node.py +++ b/data_safe_haven/infrastructure/components/composite/automation_dsc_node.py @@ -1,4 +1,5 @@ """Register a VM as an Azure Automation DSC node""" + from collections.abc import Mapping, Sequence from pulumi import ComponentResource, Input, Output, ResourceOptions diff --git a/data_safe_haven/infrastructure/components/composite/virtual_machine.py b/data_safe_haven/infrastructure/components/composite/virtual_machine.py index a12284e8df..270d4c79b9 100644 --- a/data_safe_haven/infrastructure/components/composite/virtual_machine.py +++ b/data_safe_haven/infrastructure/components/composite/virtual_machine.py @@ -1,4 +1,5 @@ """Pulumi component for virtual machines""" + from collections.abc import Mapping from typing import Any @@ -183,9 +184,9 @@ def __init__( opts=child_opts, tags=child_tags, ) - network_interface_ip_params[ - "public_ip_address" - ] = network.PublicIPAddressArgs(id=public_ip.id) + network_interface_ip_params["public_ip_address"] = ( + network.PublicIPAddressArgs(id=public_ip.id) + ) # Define network card network_interface = network.NetworkInterface( diff --git a/data_safe_haven/infrastructure/components/dynamic/azuread_application.py b/data_safe_haven/infrastructure/components/dynamic/azuread_application.py index 7834316d37..253231804b 100644 --- a/data_safe_haven/infrastructure/components/dynamic/azuread_application.py +++ b/data_safe_haven/infrastructure/components/dynamic/azuread_application.py @@ -1,4 +1,5 @@ """Pulumi dynamic component for AzureAD applications.""" + from contextlib import suppress from typing import Any diff --git a/data_safe_haven/infrastructure/components/dynamic/blob_container_acl.py b/data_safe_haven/infrastructure/components/dynamic/blob_container_acl.py index 2591876fb5..813af650d3 100644 --- a/data_safe_haven/infrastructure/components/dynamic/blob_container_acl.py +++ b/data_safe_haven/infrastructure/components/dynamic/blob_container_acl.py @@ -1,4 +1,5 @@ """Pulumi dynamic component for setting ACLs on an Azure blob container.""" + from typing import Any from pulumi import Input, Output, ResourceOptions diff --git a/data_safe_haven/infrastructure/components/dynamic/compiled_dsc.py b/data_safe_haven/infrastructure/components/dynamic/compiled_dsc.py index d9f988db67..f1b1236ef6 100644 --- a/data_safe_haven/infrastructure/components/dynamic/compiled_dsc.py +++ b/data_safe_haven/infrastructure/components/dynamic/compiled_dsc.py @@ -1,4 +1,5 @@ """Pulumi dynamic component for compiled desired state configuration.""" + from collections.abc import Sequence from typing import Any diff --git a/data_safe_haven/infrastructure/components/dynamic/dsh_resource_provider.py b/data_safe_haven/infrastructure/components/dynamic/dsh_resource_provider.py index 4d9a5dbbba..162e44e5bb 100644 --- a/data_safe_haven/infrastructure/components/dynamic/dsh_resource_provider.py +++ b/data_safe_haven/infrastructure/components/dynamic/dsh_resource_provider.py @@ -1,4 +1,5 @@ """Pulumi base dynamic component.""" + from collections.abc import Sequence from typing import Any diff --git a/data_safe_haven/infrastructure/components/dynamic/file_share_file.py b/data_safe_haven/infrastructure/components/dynamic/file_share_file.py index 7a45cbff54..3420e7a34a 100644 --- a/data_safe_haven/infrastructure/components/dynamic/file_share_file.py +++ b/data_safe_haven/infrastructure/components/dynamic/file_share_file.py @@ -1,4 +1,5 @@ """Pulumi dynamic component for files uploaded to an Azure FileShare.""" + from contextlib import suppress from typing import Any diff --git a/data_safe_haven/infrastructure/components/dynamic/file_upload.py b/data_safe_haven/infrastructure/components/dynamic/file_upload.py index 4f1f259c47..f634477da6 100644 --- a/data_safe_haven/infrastructure/components/dynamic/file_upload.py +++ b/data_safe_haven/infrastructure/components/dynamic/file_upload.py @@ -1,4 +1,5 @@ """Pulumi dynamic component for running remote scripts on an Azure VM.""" + from typing import Any from pulumi import Input, Output, ResourceOptions diff --git a/data_safe_haven/infrastructure/components/dynamic/remote_script.py b/data_safe_haven/infrastructure/components/dynamic/remote_script.py index cdedb5c0bf..dd3f03cb72 100644 --- a/data_safe_haven/infrastructure/components/dynamic/remote_script.py +++ b/data_safe_haven/infrastructure/components/dynamic/remote_script.py @@ -1,4 +1,5 @@ """Pulumi dynamic component for running remote scripts on an Azure VM.""" + from typing import Any from pulumi import Input, Output, ResourceOptions diff --git a/data_safe_haven/infrastructure/components/dynamic/ssl_certificate.py b/data_safe_haven/infrastructure/components/dynamic/ssl_certificate.py index 1b5faa4f9c..301d9ade8e 100644 --- a/data_safe_haven/infrastructure/components/dynamic/ssl_certificate.py +++ b/data_safe_haven/infrastructure/components/dynamic/ssl_certificate.py @@ -1,4 +1,5 @@ """Pulumi dynamic component for SSL certificates uploaded to an Azure KeyVault.""" + from contextlib import suppress from typing import Any diff --git a/data_safe_haven/infrastructure/components/wrapped/automation_account.py b/data_safe_haven/infrastructure/components/wrapped/automation_account.py index a7a044c9b0..bf2fa73a4e 100644 --- a/data_safe_haven/infrastructure/components/wrapped/automation_account.py +++ b/data_safe_haven/infrastructure/components/wrapped/automation_account.py @@ -1,4 +1,5 @@ """Wrapper for the Pulumi AutomationAccount component""" + from collections.abc import Mapping, Sequence import pulumi @@ -36,11 +37,13 @@ def agentsvc_url(self) -> pulumi.Output[str]: Gets the URL of the agentsvc. """ return self.automation_hybrid_service_url.apply( - lambda url: url.replace("jrds", "agentsvc").replace( - "/automationAccounts/", "/accounts/" + lambda url: ( + url.replace("jrds", "agentsvc").replace( + "/automationAccounts/", "/accounts/" + ) + if url + else "UNKNOWN" ) - if url - else "UNKNOWN" ) @property diff --git a/data_safe_haven/infrastructure/components/wrapped/log_analytics_workspace.py b/data_safe_haven/infrastructure/components/wrapped/log_analytics_workspace.py index ccd27f299d..663e3bf853 100644 --- a/data_safe_haven/infrastructure/components/wrapped/log_analytics_workspace.py +++ b/data_safe_haven/infrastructure/components/wrapped/log_analytics_workspace.py @@ -1,4 +1,5 @@ """Wrapper for the Pulumi Log Analytics Workspace component""" + from collections.abc import Mapping import pulumi @@ -49,18 +50,16 @@ def workspace_key(self) -> pulumi.Output[str]: """ Gets the key for this workspace. """ - workspace_keys: pulumi.Output[ - operationalinsights.GetSharedKeysResult - ] = pulumi.Output.all( - resource_group_name=self.resource_group_name, - workspace_name=self.name, - ).apply( - lambda kwargs: operationalinsights.get_shared_keys_output(**kwargs) + workspace_keys: pulumi.Output[operationalinsights.GetSharedKeysResult] = ( + pulumi.Output.all( + resource_group_name=self.resource_group_name, + workspace_name=self.name, + ).apply(lambda kwargs: operationalinsights.get_shared_keys_output(**kwargs)) ) return pulumi.Output.secret( workspace_keys.apply( - lambda keys: keys.primary_shared_key - if keys.primary_shared_key - else "UNKNOWN" + lambda keys: ( + keys.primary_shared_key if keys.primary_shared_key else "UNKNOWN" + ) ) ) diff --git a/data_safe_haven/infrastructure/stack_manager.py b/data_safe_haven/infrastructure/stack_manager.py index 1c4fbdafee..c2dfcc827f 100644 --- a/data_safe_haven/infrastructure/stack_manager.py +++ b/data_safe_haven/infrastructure/stack_manager.py @@ -1,4 +1,5 @@ """Deploy with Pulumi""" + import logging import pathlib import shutil diff --git a/data_safe_haven/infrastructure/stacks/declarative_shm.py b/data_safe_haven/infrastructure/stacks/declarative_shm.py index a7a93e7d91..496f924e44 100644 --- a/data_safe_haven/infrastructure/stacks/declarative_shm.py +++ b/data_safe_haven/infrastructure/stacks/declarative_shm.py @@ -1,4 +1,5 @@ """Deploy Data Safe Haven Management environment with Pulumi""" + import pulumi from data_safe_haven.config import Config diff --git a/data_safe_haven/infrastructure/stacks/declarative_sre.py b/data_safe_haven/infrastructure/stacks/declarative_sre.py index 106166ce2d..b25edec917 100644 --- a/data_safe_haven/infrastructure/stacks/declarative_sre.py +++ b/data_safe_haven/infrastructure/stacks/declarative_sre.py @@ -1,4 +1,5 @@ """Pulumi declarative program""" + import pulumi from data_safe_haven.config import Config diff --git a/data_safe_haven/infrastructure/stacks/shm/bastion.py b/data_safe_haven/infrastructure/stacks/shm/bastion.py index 307fe2cde3..f3989f2c87 100644 --- a/data_safe_haven/infrastructure/stacks/shm/bastion.py +++ b/data_safe_haven/infrastructure/stacks/shm/bastion.py @@ -1,4 +1,5 @@ """Pulumi component for SHM monitoring""" + from collections.abc import Mapping from pulumi import ComponentResource, Input, Output, ResourceOptions diff --git a/data_safe_haven/infrastructure/stacks/shm/data.py b/data_safe_haven/infrastructure/stacks/shm/data.py index 2ccc002744..cf0b1d1276 100644 --- a/data_safe_haven/infrastructure/stacks/shm/data.py +++ b/data_safe_haven/infrastructure/stacks/shm/data.py @@ -1,4 +1,5 @@ """Pulumi component for SHM state""" + from collections.abc import Mapping, Sequence import pulumi_random diff --git a/data_safe_haven/infrastructure/stacks/shm/domain_controllers.py b/data_safe_haven/infrastructure/stacks/shm/domain_controllers.py index b0f9a81ea3..ab460843a4 100644 --- a/data_safe_haven/infrastructure/stacks/shm/domain_controllers.py +++ b/data_safe_haven/infrastructure/stacks/shm/domain_controllers.py @@ -1,4 +1,5 @@ """Pulumi component for SHM domain controllers""" + from collections.abc import Mapping, Sequence from pulumi import ComponentResource, Input, Output, ResourceOptions diff --git a/data_safe_haven/infrastructure/stacks/shm/firewall.py b/data_safe_haven/infrastructure/stacks/shm/firewall.py index 04cc7d95a6..1f95d20323 100644 --- a/data_safe_haven/infrastructure/stacks/shm/firewall.py +++ b/data_safe_haven/infrastructure/stacks/shm/firewall.py @@ -1,4 +1,5 @@ """Pulumi component for SHM traffic routing""" + from collections.abc import Mapping from pulumi import ComponentResource, Input, Output, ResourceOptions @@ -621,9 +622,11 @@ def __init__( # Route all connected traffic through the firewall private_ip_address = firewall.ip_configurations.apply( - lambda cfgs: "" - if not cfgs - else next(filter(lambda _: _, [cfg.private_ip_address for cfg in cfgs])) + lambda cfgs: ( + "" + if not cfgs + else next(filter(lambda _: _, [cfg.private_ip_address for cfg in cfgs])) + ) ) network.Route( f"{self._name}_route_via_firewall", diff --git a/data_safe_haven/infrastructure/stacks/shm/monitoring.py b/data_safe_haven/infrastructure/stacks/shm/monitoring.py index d76623d1cb..8505f66b04 100644 --- a/data_safe_haven/infrastructure/stacks/shm/monitoring.py +++ b/data_safe_haven/infrastructure/stacks/shm/monitoring.py @@ -1,4 +1,5 @@ """Pulumi component for SHM monitoring""" + from collections.abc import Mapping from pulumi import ComponentResource, Input, Output, ResourceOptions diff --git a/data_safe_haven/infrastructure/stacks/shm/networking.py b/data_safe_haven/infrastructure/stacks/shm/networking.py index 28fc2d2a0f..f0271e50fc 100644 --- a/data_safe_haven/infrastructure/stacks/shm/networking.py +++ b/data_safe_haven/infrastructure/stacks/shm/networking.py @@ -1,4 +1,5 @@ """Pulumi component for SHM networking""" + from collections.abc import Mapping, Sequence from pulumi import ComponentResource, Input, Output, ResourceOptions diff --git a/data_safe_haven/infrastructure/stacks/shm/update_servers.py b/data_safe_haven/infrastructure/stacks/shm/update_servers.py index b708bd746b..3b8a9a7fba 100644 --- a/data_safe_haven/infrastructure/stacks/shm/update_servers.py +++ b/data_safe_haven/infrastructure/stacks/shm/update_servers.py @@ -1,4 +1,5 @@ """Pulumi component for SHM monitoring""" + from collections.abc import Mapping from pulumi import ComponentResource, Input, Output, ResourceOptions diff --git a/data_safe_haven/infrastructure/stacks/sre/application_gateway.py b/data_safe_haven/infrastructure/stacks/sre/application_gateway.py index 06a5452e1c..f8a0c2869c 100644 --- a/data_safe_haven/infrastructure/stacks/sre/application_gateway.py +++ b/data_safe_haven/infrastructure/stacks/sre/application_gateway.py @@ -1,4 +1,5 @@ """Pulumi component for SRE application gateway""" + from collections.abc import Mapping from typing import Any diff --git a/data_safe_haven/infrastructure/stacks/sre/backup.py b/data_safe_haven/infrastructure/stacks/sre/backup.py index 89960060fa..7ecfa0c5ae 100644 --- a/data_safe_haven/infrastructure/stacks/sre/backup.py +++ b/data_safe_haven/infrastructure/stacks/sre/backup.py @@ -1,4 +1,5 @@ """Pulumi component for SRE backup""" + from collections.abc import Mapping from pulumi import ComponentResource, Input, ResourceOptions diff --git a/data_safe_haven/infrastructure/stacks/sre/data.py b/data_safe_haven/infrastructure/stacks/sre/data.py index e1e5832462..80625e0f60 100644 --- a/data_safe_haven/infrastructure/stacks/sre/data.py +++ b/data_safe_haven/infrastructure/stacks/sre/data.py @@ -1,4 +1,5 @@ """Pulumi component for SRE data""" + from collections.abc import Mapping, Sequence from typing import ClassVar diff --git a/data_safe_haven/infrastructure/stacks/sre/dns_server.py b/data_safe_haven/infrastructure/stacks/sre/dns_server.py index 4d904be94d..da29cfca1b 100644 --- a/data_safe_haven/infrastructure/stacks/sre/dns_server.py +++ b/data_safe_haven/infrastructure/stacks/sre/dns_server.py @@ -1,4 +1,5 @@ """Pulumi component for SRE DNS server""" + from collections.abc import Mapping import pulumi_random diff --git a/data_safe_haven/infrastructure/stacks/sre/monitoring.py b/data_safe_haven/infrastructure/stacks/sre/monitoring.py index dba2c59763..955be8a47f 100644 --- a/data_safe_haven/infrastructure/stacks/sre/monitoring.py +++ b/data_safe_haven/infrastructure/stacks/sre/monitoring.py @@ -1,4 +1,5 @@ """Pulumi component for SHM monitoring""" + from collections.abc import Mapping from pulumi import ComponentResource, Input, Output, ResourceOptions diff --git a/data_safe_haven/infrastructure/stacks/sre/networking.py b/data_safe_haven/infrastructure/stacks/sre/networking.py index 6e11128044..9a3a1ec970 100644 --- a/data_safe_haven/infrastructure/stacks/sre/networking.py +++ b/data_safe_haven/infrastructure/stacks/sre/networking.py @@ -1,4 +1,5 @@ """Pulumi component for SRE networking""" + from collections.abc import Mapping from pulumi import ComponentResource, Input, Output, ResourceOptions diff --git a/data_safe_haven/infrastructure/stacks/sre/remote_desktop.py b/data_safe_haven/infrastructure/stacks/sre/remote_desktop.py index 74eaa178c7..c4d0fa7e05 100644 --- a/data_safe_haven/infrastructure/stacks/sre/remote_desktop.py +++ b/data_safe_haven/infrastructure/stacks/sre/remote_desktop.py @@ -1,4 +1,5 @@ """Pulumi component for SRE remote desktop""" + from collections.abc import Mapping from pulumi import ComponentResource, Input, Output, ResourceOptions @@ -82,11 +83,14 @@ def __init__( self.subnet_guacamole_containers_ip_addresses = Output.from_input( subnet_guacamole_containers ).apply( - lambda s: [ - str(ip) for ip in AzureIPv4Range.from_cidr(s.address_prefix).available() - ] - if s.address_prefix - else [] + lambda s: ( + [ + str(ip) + for ip in AzureIPv4Range.from_cidr(s.address_prefix).available() + ] + if s.address_prefix + else [] + ) ) self.subnet_guacamole_containers_support_id = Output.from_input( subnet_guacamole_containers_support @@ -94,11 +98,14 @@ def __init__( self.subnet_guacamole_containers_support_ip_addresses = Output.from_input( subnet_guacamole_containers_support ).apply( - lambda s: [ - str(ip) for ip in AzureIPv4Range.from_cidr(s.address_prefix).available() - ] - if s.address_prefix - else [] + lambda s: ( + [ + str(ip) + for ip in AzureIPv4Range.from_cidr(s.address_prefix).available() + ] + if s.address_prefix + else [] + ) ) self.virtual_network = virtual_network self.virtual_network_resource_group_name = virtual_network_resource_group_name diff --git a/data_safe_haven/infrastructure/stacks/sre/software_repositories.py b/data_safe_haven/infrastructure/stacks/sre/software_repositories.py index 94688e4124..7295effd2d 100644 --- a/data_safe_haven/infrastructure/stacks/sre/software_repositories.py +++ b/data_safe_haven/infrastructure/stacks/sre/software_repositories.py @@ -1,4 +1,5 @@ """Pulumi component for SRE monitoring""" + from collections.abc import Mapping from pulumi import ComponentResource, Input, Output, ResourceOptions diff --git a/data_safe_haven/provisioning/__init__.py b/data_safe_haven/provisioning/__init__.py index 38680c09a2..704c840043 100644 --- a/data_safe_haven/provisioning/__init__.py +++ b/data_safe_haven/provisioning/__init__.py @@ -1,4 +1,5 @@ """Provisioning for deployed Data Safe Haven infrastructure.""" + from .shm_provisioning_manager import SHMProvisioningManager from .sre_provisioning_manager import SREProvisioningManager diff --git a/data_safe_haven/provisioning/shm_provisioning_manager.py b/data_safe_haven/provisioning/shm_provisioning_manager.py index ab65b62601..77429a88ea 100644 --- a/data_safe_haven/provisioning/shm_provisioning_manager.py +++ b/data_safe_haven/provisioning/shm_provisioning_manager.py @@ -1,4 +1,5 @@ """Provisioning manager for a deployed SHM.""" + from data_safe_haven.external import AzureApi from data_safe_haven.infrastructure import SHMStackManager diff --git a/data_safe_haven/provisioning/sre_provisioning_manager.py b/data_safe_haven/provisioning/sre_provisioning_manager.py index e79dcae35a..56d1f0b2d0 100644 --- a/data_safe_haven/provisioning/sre_provisioning_manager.py +++ b/data_safe_haven/provisioning/sre_provisioning_manager.py @@ -1,4 +1,5 @@ """Provisioning manager for a deployed SRE.""" + import pathlib from typing import Any @@ -39,9 +40,9 @@ def __init__( # Construct remote desktop parameters self.remote_desktop_params = sre_stack.output("remote_desktop") - self.remote_desktop_params[ - "connection_db_server_password" - ] = connection_db_server_password + self.remote_desktop_params["connection_db_server_password"] = ( + connection_db_server_password + ) self.remote_desktop_params["timezone"] = timezone # Construct security group parameters diff --git a/data_safe_haven/resources/workspace/test_functionality_python.py b/data_safe_haven/resources/workspace/test_functionality_python.py index 855e5e5f15..449e76be9d 100644 --- a/data_safe_haven/resources/workspace/test_functionality_python.py +++ b/data_safe_haven/resources/workspace/test_functionality_python.py @@ -1,4 +1,5 @@ """Test logistic regression using python""" + import numpy as np import pandas as pd from sklearn.linear_model import LogisticRegression diff --git a/data_safe_haven/utility/file_reader.py b/data_safe_haven/utility/file_reader.py index eeae4ab133..0eb95f21d0 100644 --- a/data_safe_haven/utility/file_reader.py +++ b/data_safe_haven/utility/file_reader.py @@ -1,4 +1,5 @@ """Read local files, handling template expansion if needed""" + import pathlib from typing import Any diff --git a/data_safe_haven/utility/logger.py b/data_safe_haven/utility/logger.py index 7eb8967a87..f57a7f6169 100644 --- a/data_safe_haven/utility/logger.py +++ b/data_safe_haven/utility/logger.py @@ -1,4 +1,5 @@ """Standalone logging class implemented as a singleton""" + import io import logging from typing import Any, ClassVar diff --git a/data_safe_haven/utility/singleton.py b/data_safe_haven/utility/singleton.py index 46f4d9612f..137917f140 100644 --- a/data_safe_haven/utility/singleton.py +++ b/data_safe_haven/utility/singleton.py @@ -1,4 +1,5 @@ """Definition of a Singleton metaclass""" + from typing import Any, Generic, TypeVar T = TypeVar("T")