From e94a6b88cb8cdcc19ee01d1d492592b2c79da934 Mon Sep 17 00:00:00 2001 From: Raghav Pillai <76788658+raghavpillai@users.noreply.github.com> Date: Sun, 21 Jul 2024 14:01:02 -0700 Subject: [PATCH] Refactor config module with type annotations - Added type annotations to and functions - Removed unnecessary variable assignments --- src/utils/config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/config.py b/src/utils/config.py index ebcb4a1..5302fb0 100644 --- a/src/utils/config.py +++ b/src/utils/config.py @@ -6,14 +6,14 @@ CONFIG_FILE: str = os.path.join(HOME_DIR, ".gen-commit") -def read_config(): +def read_config() -> dict: if not os.path.exists(CONFIG_FILE): print( f"Config file not found at {CONFIG_FILE}. Please run `gencommit --init` to create a config file." ) sys.exit(1) - config = {} + config: dict[str, str] = {} with open(CONFIG_FILE, "r") as f: for line in f: key, value = line.strip().split("=", 1) @@ -21,10 +21,10 @@ def read_config(): return config -def read_version_from_pyproject(): +def read_version_from_pyproject() -> str: try: with open("pyproject.toml", "rb") as f: - pyproject_data = tomli.load(f) + pyproject_data: dict[str, any] = tomli.load(f) return pyproject_data["project"]["version"] except (FileNotFoundError, KeyError): return "0.0.0" # Default version if not found