Skip to content

Commit f1e1348

Browse files
committed
[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.
1 parent 5bebc1a commit f1e1348

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

email-rotation/rotations.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import datetime
55
import logging
66
from pathlib import Path
7-
from typing import Any, Dict, List
7+
from typing import Any
88

99
import yaml
1010

@@ -16,10 +16,10 @@
1616
class RotationMembersFile:
1717
"""Represents the contents of the rotation-members.yaml file."""
1818

19-
members: List[str]
19+
members: list[str]
2020

2121
@classmethod
22-
def from_yaml(cls, data: Dict[str, Any]) -> "RotationMembersFile":
22+
def from_yaml(cls, data: dict[str, Any]) -> "RotationMembersFile":
2323
"""Create an instance from a YAML dictionary."""
2424
return cls(members=data.get("members", []))
2525

@@ -46,15 +46,15 @@ class Rotation:
4646
"""Represents a single rotation entry."""
4747

4848
start_time: datetime.datetime
49-
members: List[str]
49+
members: list[str]
5050

5151
@classmethod
52-
def from_yaml(cls, data: Dict[str, Any]) -> "Rotation":
52+
def from_yaml(cls, data: dict[str, Any]) -> "Rotation":
5353
"""Create an instance from a YAML dictionary."""
5454
start_time = datetime.datetime.fromisoformat(data["start_time"])
5555
return cls(start_time=start_time, members=data.get("members", []))
5656

57-
def to_yaml(self) -> Dict[str, Any]:
57+
def to_yaml(self) -> dict[str, Any]:
5858
"""Convert the instance to a YAML-compatible dictionary."""
5959
as_dict = dataclasses.asdict(self)
6060
as_dict["start_time"] = self.start_time.isoformat()
@@ -75,10 +75,10 @@ def to_yaml(self) -> Dict[str, Any]:
7575
class RotationFile:
7676
"""Represents the contents of the rotation.yaml file."""
7777

78-
rotations: List[Rotation]
78+
rotations: list[Rotation]
7979

8080
@classmethod
81-
def from_yaml(cls, data: Dict[str, Any]) -> "RotationFile":
81+
def from_yaml(cls, data: dict[str, Any]) -> "RotationFile":
8282
"""Create an instance from a YAML dictionary."""
8383
# Subtle: sort this, so `rotations` is always in order from
8484
# oldest -> newest.

0 commit comments

Comments
 (0)