Skip to content

Commit

Permalink
add some type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
mcflugen committed Mar 12, 2024
1 parent 595aa6d commit 31d3c99
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions babelizer/errors.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
7 changes: 5 additions & 2 deletions babelizer/utils.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 31d3c99

Please sign in to comment.