From c56638aa4a75da5eb10c2cded48c30b51f60d8e0 Mon Sep 17 00:00:00 2001 From: Nathan Hoad Date: Mon, 3 Jul 2023 16:20:01 -0400 Subject: [PATCH] Add some typing annotations. --- bin/pyopen.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/pyopen.py b/bin/pyopen.py index 85205ae..b681ad6 100755 --- a/bin/pyopen.py +++ b/bin/pyopen.py @@ -1,15 +1,16 @@ import inspect import os import sys +from typing import Any, NoReturn import click -def error(message): +def error(message: str) -> NoReturn: sys.exit(f"pyopen: {message}") -def get_object(path): +def get_object(path: str) -> Any: parts = path.split(".") module = parts[0] @@ -27,7 +28,7 @@ def get_object(path): return obj -def import_path_to_file_path(path): +def import_path_to_file_path(path: str) -> tuple[str, str, list[str]]: try: obj = get_object(path) except (AttributeError, ImportError) as e: @@ -71,7 +72,7 @@ def import_path_to_file_path(path): return dirname, basename, additional_args -def get_editor(): +def get_editor() -> str: editor = os.environ.get("EDITOR", None) if editor: return editor -- 2.45.2