diff --git a/avro/core/processor.py b/avro/core/processor.py index 79c3340..7c30685 100644 --- a/avro/core/processor.py +++ b/avro/core/processor.py @@ -4,7 +4,7 @@ # Import first-party Python libraries. import contextlib from functools import lru_cache -from typing import Any, Dict, List, Optional, Tuple +from typing import Any, Optional # Import local modules. from . import config, validate @@ -21,7 +21,7 @@ @lru_cache(maxsize=128) -def find_in_remap(text: str, *, reversed: bool = False) -> Tuple[str, bool]: +def find_in_remap(text: str, *, reversed: bool = False) -> tuple[str, bool]: """ Finds and returns the remapped value for a given text. @@ -47,7 +47,7 @@ def find_in_remap(text: str, *, reversed: bool = False) -> Tuple[str, bool]: def match_patterns( fixed_text: str, cur: int = 0, rule: bool = False, reversed: bool = False -) -> Dict[str, Any]: +) -> dict[str, Any]: """ Matches given text at cursor position with rule / non rule patterns. @@ -78,7 +78,7 @@ def match_patterns( def exact_find_in_pattern( fixed_text: str, reversed: bool, cur: int = 0, patterns: Any = PATTERNS -) -> List[Dict[str, Any]]: +) -> list[dict[str, Any]]: """ Returns pattern items that match given text, cursor position and pattern. """ @@ -124,7 +124,7 @@ def reverse_with_rules(cursor: int, fixed_text: str, text_reversed: str) -> str: return text_reversed if not text_reversed else text_reversed + added_suffix -def process_rules(rules: Dict[str, Any], fixed_text: str, cur: int = 0, cur_end: int = 1) -> Optional[str]: +def process_rules(rules: dict[str, Any], fixed_text: str, cur: int = 0, cur_end: int = 1) -> Optional[str]: """ Process rules matched in pattern and returns suitable replacement. diff --git a/avro/main.py b/avro/main.py index b272df3..b36f9be 100755 --- a/avro/main.py +++ b/avro/main.py @@ -12,7 +12,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed from functools import lru_cache from itertools import chain -from typing import Callable, Generator, List, Tuple, Union +from typing import Callable, Generator, Union # Import local modules. from .core import processor, validate @@ -20,7 +20,7 @@ # Concurrency helper function for handling multithreaded workloads. -def _concurrency_helper(func: Callable, params: Tuple[str, ...]) -> List[str]: +def _concurrency_helper(func: Callable, params: tuple[str, ...]) -> list[str]: output = [] with ThreadPoolExecutor() as executor: @@ -149,7 +149,7 @@ def _reverse_backend_ext(text: str, remap_words: bool) -> str: # Primary user-end functions. # The parse() function. # Used to parse from English Roman script to Bengali in Unicode. -def parse(*texts: str, bijoy: bool = False, remap_words: bool = True) -> Union[str, List[str]]: +def parse(*texts: str, bijoy: bool = False, remap_words: bool = True) -> Union[str, list[str]]: """ #### Parses input text, matches and replaces using the Avro Dictionary. @@ -181,7 +181,7 @@ def parse(*texts: str, bijoy: bool = False, remap_words: bool = True) -> Union[s # The to_bijoy() function. # Used to parse from Bengali in Unicode to Bijoy Keyboard format. -def to_bijoy(*texts: str) -> Union[str, List[str]]: +def to_bijoy(*texts: str) -> Union[str, list[str]]: """ #### Converts input text (Avro, Unicode) to Bijoy Keyboard format (ASCII). @@ -205,7 +205,7 @@ def to_bijoy(*texts: str) -> Union[str, List[str]]: # The to_unicode() function. # Used to parse from Bijoy Keyboard format to Bengali in Unicode. -def to_unicode(*texts: str) -> Union[str, List[str]]: +def to_unicode(*texts: str) -> Union[str, list[str]]: """ #### Converts input text (Bijoy Keyboard, ASCII) to Unicode (Avro Keyboard format). @@ -229,7 +229,7 @@ def to_unicode(*texts: str) -> Union[str, List[str]]: # The reverse() function. # Used to parse from Bengali in Unicode to English Roman script. -def reverse(*texts: str, from_bijoy: bool = False, remap_words: bool = True) -> Union[str, List[str]]: +def reverse(*texts: str, from_bijoy: bool = False, remap_words: bool = True) -> Union[str, list[str]]: """ #### Reverses input text to Roman script typed in English. diff --git a/avro/resources/dictionary.py b/avro/resources/dictionary.py index 99ee998..c6e846f 100644 --- a/avro/resources/dictionary.py +++ b/avro/resources/dictionary.py @@ -2,10 +2,10 @@ # Import first-party Python modules. -from typing import Any, Dict +from typing import Any # The Avro Dictionary, implemented in Python. -DICT: Dict[str, Any] = { +DICT: dict[str, Any] = { # Metadata. "meta": { "file_name": "dictionary.py",