From f1e13483353339788a942fc0bbf18e423cf4c151 Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Tue, 9 Sep 2025 19:36:04 -0600 Subject: [PATCH] [email-rotation] use `list`/`dict` instead of `typing`; NFCI Direct use of `list`/`dict` is preferred, and something I learned about when I'd half-written this. Didn't realize I left these instances initially. --- email-rotation/rotations.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/email-rotation/rotations.py b/email-rotation/rotations.py index 444e62e..ddc2d6b 100644 --- a/email-rotation/rotations.py +++ b/email-rotation/rotations.py @@ -4,7 +4,7 @@ import datetime import logging from pathlib import Path -from typing import Any, Dict, List +from typing import Any import yaml @@ -16,10 +16,10 @@ class RotationMembersFile: """Represents the contents of the rotation-members.yaml file.""" - members: List[str] + members: list[str] @classmethod - def from_yaml(cls, data: Dict[str, Any]) -> "RotationMembersFile": + def from_yaml(cls, data: dict[str, Any]) -> "RotationMembersFile": """Create an instance from a YAML dictionary.""" return cls(members=data.get("members", [])) @@ -46,15 +46,15 @@ class Rotation: """Represents a single rotation entry.""" start_time: datetime.datetime - members: List[str] + members: list[str] @classmethod - def from_yaml(cls, data: Dict[str, Any]) -> "Rotation": + def from_yaml(cls, data: dict[str, Any]) -> "Rotation": """Create an instance from a YAML dictionary.""" start_time = datetime.datetime.fromisoformat(data["start_time"]) return cls(start_time=start_time, members=data.get("members", [])) - def to_yaml(self) -> Dict[str, Any]: + def to_yaml(self) -> dict[str, Any]: """Convert the instance to a YAML-compatible dictionary.""" as_dict = dataclasses.asdict(self) as_dict["start_time"] = self.start_time.isoformat() @@ -75,10 +75,10 @@ def to_yaml(self) -> Dict[str, Any]: class RotationFile: """Represents the contents of the rotation.yaml file.""" - rotations: List[Rotation] + rotations: list[Rotation] @classmethod - def from_yaml(cls, data: Dict[str, Any]) -> "RotationFile": + def from_yaml(cls, data: dict[str, Any]) -> "RotationFile": """Create an instance from a YAML dictionary.""" # Subtle: sort this, so `rotations` is always in order from # oldest -> newest.