Skip to content

Commit 64e1230

Browse files
committed
Fix type issues
1 parent 95794bf commit 64e1230

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/localization_translation/convert_parse.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
__license__ = "GNU General Public License Version 3"
2727

2828
from enum import IntEnum, auto
29-
from typing import Any, NamedTuple, cast
29+
from typing import Any, NamedTuple
3030

3131
from localization_translation import lua_parser
3232

@@ -67,7 +67,7 @@ class IndentFormat(NamedTuple):
6767

6868
def lang_to_dict(
6969
lang_data: str,
70-
) -> tuple[dict[int | str, Any], CommentData]:
70+
) -> tuple[dict[str | int | float, Any], CommentData]:
7171
"""Return data and comments from lua table."""
7272
all_tokens: list[lua_parser.Token] = list(lua_parser.tokenize_cst(lang_data))
7373
parser = lua_parser.Parser([t for t in all_tokens if not isinstance(t, lua_parser.CSTToken)])
@@ -134,7 +134,7 @@ def next_token() -> lua_parser.Token:
134134

135135

136136
def dict_to_lang(
137-
data: dict[str, Any],
137+
data: dict[str | int | float, Any],
138138
comments: CommentData,
139139
) -> str:
140140
"""Convert data and comments to MineOS file data."""
@@ -158,8 +158,8 @@ def cartrage_return() -> None:
158158
line = ""
159159
line += indent.indent_text
160160

161-
root = cast("dict[str | int, Any]", data)
162-
roots: list[dict[str | int, Any]] = []
161+
root = data
162+
roots: list[dict[str | int | float, Any]] = []
163163
last_key: str | int | float | None = None
164164

165165
in_blocks = 0

src/localization_translation/lua_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ def read_keyword(value: Value[str]) -> object:
678678
def convert_lists(table_data: dict[Any, Any]) -> dict[Any, Any]:
679679
"""Convert internal numeric tables to lists."""
680680

681-
def convert_dict(data: dict[Any, T]) -> dict[Any, T] | list[T]:
681+
def convert_dict(data: dict[Any, Any]) -> dict[Any, Any] | list[Any]:
682682
if all(isinstance(key, int) for key in data):
683683
return [data[i + 1] for i in range(len(data))]
684684
new = {}
@@ -697,7 +697,7 @@ def convert_dict(data: dict[Any, T]) -> dict[Any, T] | list[T]:
697697
def undo_convert_lists(table_data: dict[Any, Any]) -> dict[Any, Any]:
698698
"""Convert internal lists to numeric tables."""
699699

700-
def convert_dict(data: dict[Any, T] | list[T]) -> dict[Any, T]:
700+
def convert_dict(data: dict[Any, Any] | list[Any]) -> dict[Any, Any]:
701701
if isinstance(data, list):
702702
return {i + 1: value for i, value in enumerate(data)}
703703
new = {}

0 commit comments

Comments
 (0)