From 31d3c99addf61af1fc76e755dfc7ff2c47c4de5b Mon Sep 17 00:00:00 2001 From: mcflugen Date: Tue, 12 Mar 2024 11:30:10 -0600 Subject: [PATCH] add some type annotations --- babelizer/errors.py | 6 ++++-- babelizer/utils.py | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/babelizer/errors.py b/babelizer/errors.py index 8a06edbb..edf1abd6 100644 --- a/babelizer/errors.py +++ b/babelizer/errors.py @@ -1,13 +1,15 @@ """Exceptions raised by the *babelizer*.""" +from __future__ import annotations + class BabelizeError(Exception): """An exception that the babelizer can handle and show to the user.""" - def __init__(self, message): + def __init__(self, message: str): self._message = message - def __str__(self): + def __str__(self) -> str: """Render a user-readable error message.""" return self._message diff --git a/babelizer/utils.py b/babelizer/utils.py index c32f51db..eaa6dc40 100644 --- a/babelizer/utils.py +++ b/babelizer/utils.py @@ -1,8 +1,11 @@ """Utility functions used by the babelizer.""" +from __future__ import annotations + import pathlib import subprocess import sys +from collections.abc import Iterator from contextlib import contextmanager from contextlib import suppress @@ -36,7 +39,7 @@ def setup_py(*args): return [sys.executable, "setup.py"] + list(args) -def get_setup_py_version(): +def get_setup_py_version() -> str | None: """Get babelized package version. Returns @@ -64,7 +67,7 @@ def get_setup_py_version(): @contextmanager -def save_files(files): +def save_files(files: Iterator[str]): """Generate repository files through a context. Parameters