From b1899283c6e2fd9fa28e04a7159af584ecc62a89 Mon Sep 17 00:00:00 2001 From: HitBlast Date: Mon, 30 Dec 2024 14:04:55 +0600 Subject: [PATCH] fix pyright compatibility issues --- pyproject.toml | 2 +- src/avro/__init__.py | 2 +- src/avro/core/processor.py | 26 +++++++++++++------------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index cbe8a16..13befa9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ # uv-specific things [project] name = "avro-py" -version = "2024.12.9" +version = "2024.12.30" description = "A modern Pythonic implementation of Avro Phonetic." readme = "README.md" license = { file = "LICENSE" } diff --git a/src/avro/__init__.py b/src/avro/__init__.py index 3fce616..43299a1 100755 --- a/src/avro/__init__.py +++ b/src/avro/__init__.py @@ -31,5 +31,5 @@ from .main import * # Version information. -__version_info__ = (2024, 12, 9) +__version_info__ = (2024, 12, 30) __version__ = ".".join(map(str, __version_info__)) diff --git a/src/avro/core/processor.py b/src/avro/core/processor.py index b86f8ed..5aa54c9 100644 --- a/src/avro/core/processor.py +++ b/src/avro/core/processor.py @@ -111,7 +111,9 @@ def match_patterns( "matched": True, "found": p.get("find"), "replaced": p.get("replace"), - "reversed": reverse_with_rules(cur, fixed_text, p.get("reverse")) + "reversed": reverse_with_rules( + cur, fixed_text, p.get("reverse", None) + ) if not rule else None, "rules": p.get("rules") if rule else None, @@ -213,7 +215,7 @@ def reverse_with_rules( def process_rules( - rules: dict[str, Any], fixed_text: str, cur: int = 0, cur_end: int = 1 + rules: Any, fixed_text: str, cur: int = 0, cur_end: int = 1 ) -> Optional[str]: """Process rules matched in pattern and returns suitable replacement. @@ -242,6 +244,7 @@ def process_rules( """ replaced = "" + matched = False # Iterate through rules. for rule in rules: @@ -408,17 +411,13 @@ def rearrange_unicode_text(text: str) -> str: else: break - ( - chars[i - 1], - chars[i], - chars[i + 1 : i + j + found_pre_kar + 1], - chars[i + j + 1 :], - ) = ( - chars[i + j + 1], - chars[i + 1 : i + j + 1], - chars[i - 1], - chars[i], - chars[i + j + found_pre_kar + 1 :], + chars = ( + chars[: i - 1] + + [chars[i + j + 1]] + + chars[i + 1 : i + j + 1] + + [chars[i - 1]] + + [chars[i]] + + chars[i + j + found_pre_kar + 1 :] ) i += j + found_pre_kar barrier = i + 1 @@ -510,6 +509,7 @@ def rearrange_bijoy_text(text: str) -> str: and text[i + 1] != " " ): j = 1 + part = "" while validate.is_bangla_banjonborno(text[i + j]): if validate.is_bangla_halant((part := text[i + j + 1])): j += 2