From 7ac2c9f056927312645509d236585d4958805621 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Wed, 28 Aug 2019 13:16:29 +0200 Subject: Added correct type annotations --- patternutils/commands/pmatch.py | 4 ++-- patternutils/config.py | 4 ++-- patternutils/match.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/patternutils/commands/pmatch.py b/patternutils/commands/pmatch.py index 35285db..5f473e8 100644 --- a/patternutils/commands/pmatch.py +++ b/patternutils/commands/pmatch.py @@ -26,9 +26,9 @@ def walk(dir: str, recursive: bool = False, match_directories: bool = False) -> def apply_regex( walk_function: Iterator[Any], - regex_pattern: Pattern, + regex_pattern: Pattern[str], match_full_path: bool, -) -> Tuple[List[Dict], bool]: +) -> Tuple[List[Dict[str, str]], bool]: matches = [] has_invalid_matches = False diff --git a/patternutils/config.py b/patternutils/config.py index 1613fb9..4b95cf4 100644 --- a/patternutils/config.py +++ b/patternutils/config.py @@ -3,7 +3,7 @@ import glob import click -from typing import Tuple, List +from typing import Tuple, List, Optional CONFIG_PATH = click.get_app_dir('patternutils') @@ -31,7 +31,7 @@ def load_template(template_name: str, command_name: str) -> Tuple[str, str]: return output_pattern, template_engine -def find_templates(template_name: str, command_name: str = None) -> List[str]: +def find_templates(template_name: str, command_name: Optional[str] = None) -> List[str]: template_glob = '{}.*'.format(template_name) command_glob = '*' if command_name is None else command_name command_glob = os.path.join(CONFIG_PATH, command_glob) diff --git a/patternutils/match.py b/patternutils/match.py index e4bf470..01411c2 100644 --- a/patternutils/match.py +++ b/patternutils/match.py @@ -1,7 +1,7 @@ from typing import Pattern, Dict -def apply(subject: str, regex_pattern: Pattern) -> Dict[str, str]: +def apply(subject: str, regex_pattern: Pattern[str]) -> Dict[str, str]: match = regex_pattern.search(subject) if match is not None: groupdict = match.groupdict() -- cgit v1.3.1