Skip to content

Commit 4ae9a8e

Browse files
author
Sergei Nikiforov
committed
remove unused variable
1 parent dbeaf43 commit 4ae9a8e

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

typegen/generate_typing.py

+5-12
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ def write_annotations(output_folder: Path, strict: bool) -> None:
1919
None
2020
"""
2121
generate_template = _generate_type_safe_template if strict else _generate_union_template
22-
for dimensions in _DIMENSION_TYPES:
22+
for dimensions, filename in _DIMENSIONS_TO_FILENAME.items():
2323
contents = "\n".join(_annotate_type(dimensions, type_name, strict) for type_name in _DATA_TYPES)
2424
all_types = "\n".join(
2525
_indent(f"{_quote(full_type_name)},") for full_type_name in _list_all_types(dimensions, strict)
2626
)
2727
filename = output_folder / _DIMENSIONS_TO_FILENAME[dimensions]
2828
print(f"Writing {filename}..")
2929
with open(filename, "w") as f:
30-
f.write(generate_template(dimensions, contents, all_types))
30+
f.write(generate_template(contents, all_types))
3131

3232

3333
_DATA_TYPES: Final[dict[str, str]] = {
@@ -52,13 +52,6 @@ def write_annotations(output_folder: Path, strict: bool) -> None:
5252
"Timedelta64": "np.timedelta64",
5353
}
5454

55-
_DIMENSION_TYPES: Final[dict[int, str]] = {
56-
0: "tuple[int, ...]",
57-
1: "tuple[int, ...]",
58-
2: "tuple[int, ...]",
59-
3: "tuple[int, ...]",
60-
}
61-
6255
_DIMENSIONS_TO_PREFIX: Final[dict[int, str]] = {
6356
0: "NDArray",
6457
1: "1DArray",
@@ -103,11 +96,11 @@ def _union_type(dimension_type: str, dtype: str) -> str:
10396

10497

10598
def _annotate_type(dimensions: int, type_name: str, strict: bool) -> str:
106-
dimension_type = _DIMENSION_TYPES[dimensions]
10799
type_with_prefix = _type_name_with_prefix(dimensions, type_name, strict)
108100
data_type = _DATA_TYPES[type_name]
109101

110102
dtype = "Any" if data_type == "None" else data_type
103+
dimension_type = "tuple[int, ...]"
111104
T = _strict_type(dimension_type, dtype) if strict else _union_type(dimension_type, dtype)
112105
dim = dimensions if dimensions > 0 else None
113106
annotation = f"""{type_with_prefix}: TypeAlias = Annotated[
@@ -118,7 +111,7 @@ def _annotate_type(dimensions: int, type_name: str, strict: bool) -> str:
118111
return _unindent(annotation)
119112

120113

121-
def _generate_type_safe_template(dimensions: int, contents: str, all_types: str) -> str:
114+
def _generate_type_safe_template(contents: str, all_types: str) -> str:
122115
template = f"""from typing import Annotated, Any, TypeAlias
123116
124117
import numpy as np
@@ -134,7 +127,7 @@ def _generate_type_safe_template(dimensions: int, contents: str, all_types: str)
134127
return template
135128

136129

137-
def _generate_union_template(dimensions: int, contents: str, all_types: str) -> str:
130+
def _generate_union_template(contents: str, all_types: str) -> str:
138131
template = f"""from typing import Annotated, Any, TypeAlias, Union
139132
140133
import numpy as np

0 commit comments

Comments
 (0)