Skip to content

Commit

Permalink
Fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
JimMadge committed Apr 18, 2024
1 parent 5a38b8f commit caeadc7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions data_safe_haven/config/pulumi.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from typing import Annotated

import yaml
Expand All @@ -23,17 +25,19 @@ class PulumiStack(BaseModel, validate_assignment=True):
name: str
config: B64String

def __eq__(self, other):
def __eq__(self, other: object) -> bool:
if not isinstance(other, PulumiStack):
return NotImplemented
return self.name == other.name or self.config == other.config

def __hash__(self):
def __hash__(self) -> int:
return hash(self.name)


class PulumiConfig(BaseModel, validate_assignment=True):
stacks: UniqueList[PulumiStack]

def __getitem__(self, key: str):
def __getitem__(self, key: str) -> PulumiStack:
if not isinstance(key, str):
msg = "'key' must be a string."
raise TypeError(msg)
Expand All @@ -45,7 +49,7 @@ def __getitem__(self, key: str):
msg = f"No configuration for Pulumi stack {key}."
raise IndexError(msg)

def __setitem__(self, key: str, value: PulumiStack):
def __setitem__(self, key: str, value: PulumiStack) -> None:
if not isinstance(key, str):
msg = "'key' must be a string."
raise TypeError(msg)
Expand All @@ -56,7 +60,7 @@ def __setitem__(self, key: str, value: PulumiStack):

self.stacks.append(value)

def __delitem__(self, key: str):
def __delitem__(self, key: str) -> None:
if not isinstance(key, str):
msg = "'key' must be a string."
raise TypeError(msg)
Expand All @@ -70,7 +74,7 @@ def __delitem__(self, key: str):
raise IndexError(msg)

@property
def stack_names(self):
def stack_names(self) -> list[str]:
return [stack.name for stack in self.stacks]

def to_yaml(self) -> str:
Expand Down

0 comments on commit caeadc7

Please sign in to comment.