From 37a1a7002e420d18a3065b9ca2d3040bb3b6cf7d Mon Sep 17 00:00:00 2001 From: Hannes Schmidt Date: Fri, 31 Jan 2025 22:36:47 -0800 Subject: [PATCH] [p] Cover azul.template with mypy (#6821) --- .mypy.ini | 3 ++- src/azul/template.py | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.mypy.ini b/.mypy.ini index 8e67635fc2..660e60f0e7 100644 --- a/.mypy.ini +++ b/.mypy.ini @@ -39,7 +39,8 @@ modules = azul.modules, azul.oauth2, azul.objects, - azul.queues + azul.queues, + azul.template packages = azul.openapi diff --git a/src/azul/template.py b/src/azul/template.py index 92486af9b3..1f39030b1d 100644 --- a/src/azul/template.py +++ b/src/azul/template.py @@ -1,6 +1,3 @@ -from collections.abc import ( - Mapping, -) from contextlib import ( contextmanager, ) @@ -9,12 +6,15 @@ import sys import tempfile from typing import ( - Any, - Optional, + IO, +) + +from azul.types import ( + AnyJSON, ) -def emit(json_doc: Optional[Mapping[str, Any]]): +def emit(json_doc: AnyJSON | None): with emit_text(remove=json_doc is None) as f: json.dump(json_doc, f, indent=4) @@ -22,6 +22,7 @@ def emit(json_doc: Optional[Mapping[str, Any]]): @contextmanager def emit_text(*, remove: bool = False): path = sys.argv[1] + f: IO[str] if remove: try: os.unlink(path)