Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply changes from updated black version #1718

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Interact with users in an Azure Active Directory"""

import pathlib
from collections.abc import Sequence
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/administration/users/azure_ad_users.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Interact with users in an Azure Active Directory"""

from collections.abc import Sequence
from typing import Any

Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Command line entrypoint for Data Safe Haven application"""

import pathlib
from typing import Annotated, Optional

Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/commands/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Command-line application for performing administrative tasks"""

import pathlib
from typing import Annotated

Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/commands/admin_add_users.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Add users to a deployed Data Safe Haven"""

import pathlib

from data_safe_haven.administration.users import UserHandler
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/commands/admin_list_users.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/commands/admin_register_users.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/commands/admin_remove_users.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/commands/admin_unregister_users.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/commands/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Command group and entrypoints for managing DSH configuration"""

from pathlib import Path
from typing import Annotated, Optional

Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/commands/context.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Command group and entrypoints for managing a DSH context"""

from typing import Annotated, Optional

import typer
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/commands/deploy.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/commands/teardown.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/config/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Configuration file backed by blob storage"""

from __future__ import annotations

from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/config/context_settings.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
9 changes: 5 additions & 4 deletions data_safe_haven/external/api/azure_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Interface to the Azure Python SDK"""

import time
from collections.abc import Sequence
from contextlib import suppress
Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/external/api/azure_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Interface to the Azure CLI"""

import json
import subprocess
from dataclasses import dataclass
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/external/api/graph_api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Interface to the Microsoft Graph API"""

import datetime
import pathlib
import time
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/external/interface/azure_authenticator.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/external/interface/azure_fileshare.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Helper class for Azure fileshares"""

from contextlib import suppress

from azure.core.exceptions import ResourceNotFoundError
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/infrastructure/common/ip_ranges.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Calculate SRE IP address ranges for a given SRE index"""

from data_safe_haven.external import AzureIPv4Range


Expand Down
21 changes: 14 additions & 7 deletions data_safe_haven/infrastructure/common/transformations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Common transformations needed when manipulating Pulumi resources"""

from pulumi import Output
from pulumi_azure_native import containerinstance, network, resources

Expand Down Expand Up @@ -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 ""
)
)


Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pulumi component for virtual machines"""

from collections.abc import Mapping
from typing import Any

Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pulumi dynamic component for AzureAD applications."""

from contextlib import suppress
from typing import Any

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pulumi dynamic component for compiled desired state configuration."""

from collections.abc import Sequence
from typing import Any

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pulumi base dynamic component."""

from collections.abc import Sequence
from typing import Any

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pulumi dynamic component for files uploaded to an Azure FileShare."""

from contextlib import suppress
from typing import Any

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pulumi dynamic component for SSL certificates uploaded to an Azure KeyVault."""

from contextlib import suppress
from typing import Any

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Wrapper for the Pulumi AutomationAccount component"""

from collections.abc import Mapping, Sequence

import pulumi
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Wrapper for the Pulumi Log Analytics Workspace component"""

from collections.abc import Mapping

import pulumi
Expand Down Expand Up @@ -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"
)
)
)
1 change: 1 addition & 0 deletions data_safe_haven/infrastructure/stack_manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Deploy with Pulumi"""

import logging
import pathlib
import shutil
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/infrastructure/stacks/declarative_shm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Deploy Data Safe Haven Management environment with Pulumi"""

import pulumi

from data_safe_haven.config import Config
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/infrastructure/stacks/declarative_sre.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pulumi declarative program"""

import pulumi

from data_safe_haven.config import Config
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/infrastructure/stacks/shm/bastion.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pulumi component for SHM monitoring"""

from collections.abc import Mapping

from pulumi import ComponentResource, Input, Output, ResourceOptions
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/infrastructure/stacks/shm/data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pulumi component for SHM state"""

from collections.abc import Mapping, Sequence

import pulumi_random
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pulumi component for SHM domain controllers"""

from collections.abc import Mapping, Sequence

from pulumi import ComponentResource, Input, Output, ResourceOptions
Expand Down
9 changes: 6 additions & 3 deletions data_safe_haven/infrastructure/stacks/shm/firewall.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pulumi component for SHM traffic routing"""

from collections.abc import Mapping

from pulumi import ComponentResource, Input, Output, ResourceOptions
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/infrastructure/stacks/shm/monitoring.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pulumi component for SHM monitoring"""

from collections.abc import Mapping

from pulumi import ComponentResource, Input, Output, ResourceOptions
Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/infrastructure/stacks/shm/networking.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pulumi component for SHM networking"""

from collections.abc import Mapping, Sequence

from pulumi import ComponentResource, Input, Output, ResourceOptions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pulumi component for SHM monitoring"""

from collections.abc import Mapping

from pulumi import ComponentResource, Input, Output, ResourceOptions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pulumi component for SRE application gateway"""

from collections.abc import Mapping
from typing import Any

Expand Down
1 change: 1 addition & 0 deletions data_safe_haven/infrastructure/stacks/sre/backup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Pulumi component for SRE backup"""

from collections.abc import Mapping

from pulumi import ComponentResource, Input, ResourceOptions
Expand Down
Loading
Loading