Skip to content

Commit

Permalink
[p] Cover azul.template with mypy (#6821)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannes-ucsc committed Feb 3, 2025
1 parent cc0ef6f commit 37a1a70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ modules =
azul.modules,
azul.oauth2,
azul.objects,
azul.queues
azul.queues,
azul.template
packages =
azul.openapi

Expand Down
13 changes: 7 additions & 6 deletions src/azul/template.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from collections.abc import (
Mapping,
)
from contextlib import (
contextmanager,
)
Expand All @@ -9,19 +6,23 @@
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)


@contextmanager
def emit_text(*, remove: bool = False):
path = sys.argv[1]
f: IO[str]
if remove:
try:
os.unlink(path)
Expand Down

0 comments on commit 37a1a70

Please sign in to comment.