Skip to content

Commit

Permalink
incorporated PEP 585 into code
Browse files Browse the repository at this point in the history
  • Loading branch information
hitblast committed Oct 9, 2024
1 parent 38564b8 commit c39bfbb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions avro/core/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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.
Expand Down
12 changes: 6 additions & 6 deletions avro/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
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
from .core.config import BIJOY_MAP, BIJOY_MAP_REVERSE


# 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:
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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).
Expand All @@ -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).
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions avro/resources/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit c39bfbb

Please sign in to comment.