diff options
Diffstat (limited to '')
| -rw-r--r-- | patternutils/commands/patterncfg.py | 6 | ||||
| -rw-r--r-- | patternutils/commands/pmatch.py | 4 | ||||
| -rw-r--r-- | patternutils/commands/pmediainfo.py | 4 | ||||
| -rw-r--r-- | patternutils/commands/prss.py | 4 | ||||
| -rw-r--r-- | patternutils/config.py | 6 | ||||
| -rw-r--r-- | patternutils/types.py | 24 | ||||
| -rw-r--r-- | patternutils/utils.py | 8 |
7 files changed, 29 insertions, 27 deletions
diff --git a/patternutils/commands/patterncfg.py b/patternutils/commands/patterncfg.py index 5972397..f30a39a 100644 --- a/patternutils/commands/patterncfg.py +++ b/patternutils/commands/patterncfg.py @@ -1,7 +1,7 @@ import itertools import os import os.path -from typing import Literal, Optional, get_args +from typing import Literal, get_args import click @@ -65,7 +65,7 @@ def list() -> None: @click.argument("command", required=True, type=click.Choice(CURRENT_SUPPORTED_PROGRAMS)) @click.argument("name") def add( - template_engine: Optional[TemplateExtensions], + template_engine: TemplateExtensions | None, command: str, name: str, ) -> None: @@ -88,7 +88,7 @@ def add( help="Specify the command from which to remove the file.", ) @click.argument("name") -def remove(command: Optional[PredefinedCommands], name: str) -> None: +def remove(command: PredefinedCommands | None, name: str) -> None: """Removes a specified template file.""" files = config.find_templates(name, command) diff --git a/patternutils/commands/pmatch.py b/patternutils/commands/pmatch.py index 20f71a1..7d02ac3 100644 --- a/patternutils/commands/pmatch.py +++ b/patternutils/commands/pmatch.py @@ -3,7 +3,7 @@ import itertools import os import os.path import re -from typing import Generator, Iterator, Optional, Pattern +from typing import Generator, Iterator, Pattern import click @@ -15,7 +15,7 @@ def apply_regex( walk_function: Iterator[os.DirEntry[str]], regex_pattern: Pattern[str], match_full_path: bool, -) -> Generator[Optional[dict[str, str]], None, None]: +) -> Generator[dict[str, str] | None, None, None]: """Applies a regex pattern to directory entries and yields matched data. Args: diff --git a/patternutils/commands/pmediainfo.py b/patternutils/commands/pmediainfo.py index 35f9d4c..2cc0f8f 100644 --- a/patternutils/commands/pmediainfo.py +++ b/patternutils/commands/pmediainfo.py @@ -1,7 +1,7 @@ import functools import itertools import os.path -from typing import Any, Generator, Iterator, Optional +from typing import Any, Generator, Iterator, import click from pymediainfo import MediaInfo @@ -11,7 +11,7 @@ from .. import utils def apply_mediainfo( walk_function: Iterator[os.DirEntry[str]], -) -> Generator[Optional[dict[str, Any]], None, None]: +) -> Generator[dict[str, Any] | None, None, None]: for f in walk_function: media_info_raw = MediaInfo.parse(os.path.abspath(f)) if len(media_info_raw.tracks) <= 1: diff --git a/patternutils/commands/prss.py b/patternutils/commands/prss.py index d4232ee..9385a7f 100644 --- a/patternutils/commands/prss.py +++ b/patternutils/commands/prss.py @@ -2,7 +2,7 @@ import functools import itertools import os import os.path -from typing import Any, Generator, Optional +from typing import Any, Generator import click @@ -19,7 +19,7 @@ def match( parsed_feed: feedparser.util.FeedParserDict, walk_function: functools.partial[Generator[os.DirEntry[Any], None, None]], directory: list[str], -) -> Generator[Optional[dict[str, str]], None, None]: +) -> Generator[dict[str, str] | None, None, None]: direntries = [] filenames = [] diff --git a/patternutils/config.py b/patternutils/config.py index 785dbb3..88a86ed 100644 --- a/patternutils/config.py +++ b/patternutils/config.py @@ -2,7 +2,7 @@ import glob import os.path import re from pathlib import Path -from typing import Optional, cast, get_args, overload +from typing import cast, get_args, overload import click @@ -37,7 +37,7 @@ def load_template( def load_template( template_name: str, - command_name: Optional[PredefinedCommands], + command_name: PredefinedCommands | None, prefer: TemplatePrefer = None, ) -> tuple[str, PredefinedExtensions]: """Load a template from the config directory. @@ -82,7 +82,7 @@ def load_template( def find_templates( template_name: str, - command_name: Optional[PredefinedCommands] = None, + command_name: PredefinedCommands | None = None, prefer: TemplatePrefer = None, ) -> list[str]: """Finds matching template files based on the template name and command. diff --git a/patternutils/types.py b/patternutils/types.py index cbab184..a81eb34 100644 --- a/patternutils/types.py +++ b/patternutils/types.py @@ -1,17 +1,19 @@ -from typing import Literal, Optional +from typing import Literal -PlainCommands = Literal["pmediainfo"] +type PlainCommands = Literal["pmediainfo"] -RegexCommands = Literal["pmatch", "pjson"] -RegexExtensions = Literal["regex"] +type RegexCommands = Literal["pmatch", "pjson"] +type RegexExtensions = Literal["regex"] -TemplateCommands = Literal["tmv", "targs", "tln"] -TemplateExtensions = Literal["python", "jinja2"] +type TemplateCommands = Literal["tmv", "targs", "tln"] +type TemplateExtensions = Literal["python", "jinja2"] -PredefinedCommands = Literal[RegexCommands, TemplateCommands] -PredefinedExtensions = Literal[TemplateExtensions, RegexExtensions] +type PredefinedCommands = Literal[RegexCommands, TemplateCommands] +type PredefinedExtensions = Literal[TemplateExtensions, RegexExtensions] -CommandNames = Literal[PlainCommands, TemplateCommands, RegexCommands] +type CommandNames = Literal[PlainCommands, TemplateCommands, RegexCommands] -RegexFlags = Literal["ascii", "a", "ignorecase", "i", "multiline", "m", "dotall", "s"] -TemplatePrefer = Optional[Literal["global", "command"]] +type RegexFlags = Literal[ + "ascii", "a", "ignorecase", "i", "multiline", "m", "dotall", "s" +] +type TemplatePrefer = Literal["global", "command"] | None diff --git a/patternutils/utils.py b/patternutils/utils.py index cc0683b..6a57457 100644 --- a/patternutils/utils.py +++ b/patternutils/utils.py @@ -2,7 +2,7 @@ import json import os import re from collections.abc import Container -from typing import Any, Generator, Optional, overload +from typing import Any, Generator, overload import click @@ -16,14 +16,14 @@ def max_procs() -> int: @overload -def edit(data: dict[str, str]) -> Optional[dict[str, str]]: ... +def edit(data: dict[str, str]) -> dict[str, str] | None: ... @overload -def edit(data: list[str]) -> Optional[list[str]]: ... +def edit(data: list[str]) -> list[str] | None: ... -def edit(data: dict[str, str] | list[str]) -> Optional[dict[str, str] | list[str]]: +def edit(data: dict[str, str] | list[str]) -> dict[str, str] | list[str] | None: """Opens an interactive editor for modifying dictionary or list entries. Args: |
