Skip to content

Commit

Permalink
Type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
henryborchers committed Oct 6, 2023
1 parent 333f02c commit f33ae22
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion hathizip/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from hathizip import cli


def main():
def main() -> None:
"""Check if pytest arg is run else run main entry point."""
if len(sys.argv) > 1 and sys.argv[1] == "--pytest":
# pylint: disable=import-outside-toplevel
Expand Down
6 changes: 4 additions & 2 deletions hathizip/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
import os
import shutil
import sys
from typing import Optional, List

from hathizip import process, configure_logging
from hathizip.utils import has_subdirs


try:
from importlib import metadata
except ImportError:
import importlib_metadata as metadata # type: ignore


def destination_path(path):
def destination_path(path: str) -> str:
"""Validate the entry point for the cli args.
Args:
Expand Down Expand Up @@ -85,7 +87,7 @@ def get_parser() -> argparse.ArgumentParser:
return parser


def main(argv=None):
def main(argv: Optional[List[str]] = None) -> None:
"""Run main entry point for the program."""
argv = argv or sys.argv[1:]

Expand Down
6 changes: 5 additions & 1 deletion hathizip/configure_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import logging
import sys
from typing import Optional


def configure_logger(debug_mode=False, log_file=None) -> logging.Logger:
def configure_logger(
debug_mode: bool = False,
log_file: Optional[str] = None
) -> logging.Logger:
"""Configure logger.
Useful for passing logging information
Expand Down
6 changes: 3 additions & 3 deletions hathizip/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


# TODO: create get_files testing
def get_files(path) -> typing.Iterator[PackageFile]:
def get_files(path: str) -> typing.Iterator[PackageFile]:
"""Find files relative to a given path.
Args:
Expand All @@ -33,7 +33,7 @@ def get_files(path) -> typing.Iterator[PackageFile]:
)


def compress_folder(path, dst):
def compress_folder(path: str, dst: str) -> None:
"""Compress the contents of a path.
Args:
Expand Down Expand Up @@ -66,7 +66,7 @@ def compress_folder(path, dst):
logger.info("Generated {}".format(final_zip))


def compress_folder_inplace(path, dst):
def compress_folder_inplace(path: str, dst: str) -> None:
"""Compress the contents of a path without using a temp directory.
Args:
Expand Down

0 comments on commit f33ae22

Please sign in to comment.