Skip to content

Commit 9ae7dc6

Browse files
authored
Merge pull request #247 from tetengo/python_upgrade
Python upgrade
2 parents 3fe9a4e + 62c6f7e commit 9ae7dc6

File tree

9 files changed

+46
-46
lines changed

9 files changed

+46
-46
lines changed

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ AC_ARG_WITH(
170170
AC_CHECK_PROG(MYPY, mypy, mypy)
171171
test -z $MYPY && \
172172
AC_MSG_WARN([You cannot check the python script files for lack of mypy.])
173+
AC_SUBST([MYPY_OPTS], "--strict")
173174

174175
AC_ARG_WITH(
175176
doxygen,

kogyan

setup/installer/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ EXTRA_DIST = \
1919

2020

2121
mypy: ${script_files}
22-
${MYPY} ${srcdir}
22+
${MYPY} ${MYPY_OPTS} ${srcdir}
2323

2424
format: ${script_files}
2525
${BLACK} ${srcdir}

setup/installer/copy_libimage_files.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import re
99
import shutil
1010
import sys
11-
from typing import List, Optional, Tuple
11+
from typing import Optional
1212

1313

14-
def main(args: List[str]) -> None:
14+
def main(args: list[str]) -> None:
1515
"""The main function.
1616
1717
Args:
@@ -23,12 +23,12 @@ def main(args: List[str]) -> None:
2323
file=sys.stderr,
2424
)
2525
sys.exit(0)
26-
files: List[Tuple[pathlib.Path, pathlib.Path]] = _list_files(pathlib.Path(args[0]))
26+
files: list[tuple[pathlib.Path, pathlib.Path]] = _list_files(pathlib.Path(args[0]))
2727
_copy_files(files, pathlib.Path(args[1]))
2828

2929

30-
def _list_files(source_path: pathlib.Path) -> List[Tuple[pathlib.Path, pathlib.Path]]:
31-
files: List[Tuple[pathlib.Path, pathlib.Path]] = []
30+
def _list_files(source_path: pathlib.Path) -> list[tuple[pathlib.Path, pathlib.Path]]:
31+
files: list[tuple[pathlib.Path, pathlib.Path]] = []
3232
with source_path.open(mode="r", encoding="UTF-8") as stream:
3333
for line in stream:
3434
matched: Optional[re.Match[str]] = re.match(
@@ -57,7 +57,7 @@ def _list_files(source_path: pathlib.Path) -> List[Tuple[pathlib.Path, pathlib.P
5757

5858

5959
def _copy_files(
60-
files: List[Tuple[pathlib.Path, pathlib.Path]], destination_root: pathlib.Path
60+
files: list[tuple[pathlib.Path, pathlib.Path]], destination_root: pathlib.Path
6161
) -> None:
6262
shutil.rmtree(destination_root, ignore_errors=True)
6363
for file in files:

setup/installer/generate_content_wxs.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import pathlib
99
import re
1010
import sys
11-
from typing import Dict, List, Optional, TextIO, Tuple
11+
from typing import Any, Optional, TextIO
1212

1313

14-
def main(args: List[str]) -> None:
14+
def main(args: list[str]) -> None:
1515
"""The main function.
1616
1717
Args:
@@ -28,7 +28,7 @@ def main(args: List[str]) -> None:
2828
wxs_path = pathlib.Path(args[1])
2929

3030
destination_tree: _DestinationDirectory = _build_destination_tree(source_path)
31-
feature_map: Dict[str, List[str]] = _build_feature_map(destination_tree)
31+
feature_map: dict[str, list[str]] = _build_feature_map(destination_tree)
3232
_save_wxs(destination_tree, feature_map, wxs_path)
3333

3434

@@ -76,17 +76,17 @@ class _DestinationDirectory:
7676

7777
level: int
7878

79-
children: Dict
79+
children: dict[str, Any]
8080

81-
files: List[File]
81+
files: list[File]
8282

83-
envvars: List[EnvVar]
83+
envvars: list[EnvVar]
8484

8585
def __init__(self, id: str, name: str, level: int):
8686
self.id = id
8787
self.name = name
8888
self.level = level
89-
self.children: Dict[str, _DestinationDirectory] = {}
89+
self.children: dict[str, _DestinationDirectory] = {}
9090
self.files = []
9191
self.envvars = []
9292

@@ -154,14 +154,14 @@ def _build_destination_tree(source_path: pathlib.Path) -> _DestinationDirectory:
154154
return destination_tree
155155

156156

157-
def _build_feature_map(destination_tree: _DestinationDirectory) -> Dict[str, List[str]]:
158-
map: Dict[str, List[str]] = {}
157+
def _build_feature_map(destination_tree: _DestinationDirectory) -> dict[str, list[str]]:
158+
map: dict[str, list[str]] = {}
159159
_build_feature_map_iter(destination_tree, map)
160160
return map
161161

162162

163163
def _build_feature_map_iter(
164-
destination_tree: _DestinationDirectory, feature_map: Dict[str, List[str]]
164+
destination_tree: _DestinationDirectory, feature_map: dict[str, list[str]]
165165
) -> None:
166166
for file in destination_tree.files:
167167
if not file.feature in feature_map:
@@ -177,7 +177,7 @@ def _build_feature_map_iter(
177177

178178
def _save_wxs(
179179
destination_tree: _DestinationDirectory,
180-
feature_map: Dict[str, List[str]],
180+
feature_map: dict[str, list[str]],
181181
wxs_path: pathlib.Path,
182182
) -> None:
183183
preamble: str = """<?xml version="1.0" encoding="UTF-8"?>
@@ -248,7 +248,7 @@ def _write_directory_fragment_iter(
248248
print("{}</Directory>".format(indent), file=stream)
249249

250250

251-
def _write_feature_fragment(feature_map: Dict[str, List[str]], stream: TextIO):
251+
def _write_feature_fragment(feature_map: dict[str, list[str]], stream: TextIO) -> None:
252252
print(' <Fragment Id="Features">', file=stream)
253253
print(' <Feature Id="All">', file=stream)
254254
for feature in feature_map:

setup/installer/generate_content_wxs_source.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
import re
1010
import sys
1111
import uuid
12-
from typing import Dict, List, Optional, Tuple
12+
from typing import Optional
1313

1414

15-
def main(args: List[str]) -> None:
15+
def main(args: list[str]) -> None:
1616
"""The main function.
1717
1818
Args:
@@ -48,8 +48,8 @@ def main(args: List[str]) -> None:
4848

4949
def _load_files_to_install(
5050
path: pathlib.Path,
51-
) -> List[Tuple[str, pathlib.Path, pathlib.Path]]:
52-
files: List[Tuple[str, pathlib.Path, pathlib.Path]] = []
51+
) -> list[tuple[str, pathlib.Path, pathlib.Path]]:
52+
files: list[tuple[str, pathlib.Path, pathlib.Path]] = []
5353
with path.open(mode="r", encoding="UTF-8") as stream:
5454
for line in stream:
5555
line = line.rstrip("\r\n")
@@ -68,8 +68,8 @@ def _load_files_to_install(
6868
return files
6969

7070

71-
def _load_envvars_to_install(path: pathlib.Path) -> List[Tuple[str, str, str]]:
72-
envvars: List[Tuple[str, str, str]] = []
71+
def _load_envvars_to_install(path: pathlib.Path) -> list[tuple[str, str, str]]:
72+
envvars: list[tuple[str, str, str]] = []
7373
with path.open(mode="r", encoding="UTF-8") as stream:
7474
for line in stream:
7575
matched: Optional[re.Match[str]] = re.match(
@@ -82,7 +82,7 @@ def _load_envvars_to_install(path: pathlib.Path) -> List[Tuple[str, str, str]]:
8282

8383

8484
class _FileGuidMap:
85-
_map: Dict[pathlib.Path, Tuple[str, bool]] = {}
85+
_map: dict[pathlib.Path, tuple[str, bool]] = {}
8686

8787
def __init__(self, file_guid_map_path: pathlib.Path, solution_path: pathlib.Path):
8888
with file_guid_map_path.open(mode="r", encoding="UTF-8") as stream:
@@ -111,9 +111,9 @@ def save(self, file_guid_map_path: pathlib.Path) -> None:
111111

112112

113113
def _make_content_wxs_source(
114-
files_to_install: List[Tuple[str, pathlib.Path, pathlib.Path]],
114+
files_to_install: list[tuple[str, pathlib.Path, pathlib.Path]],
115115
file_guid_map: _FileGuidMap,
116-
envvars_to_install: List[Tuple[str, str, str]],
116+
envvars_to_install: list[tuple[str, str, str]],
117117
content_wxs_source_path: pathlib.Path,
118118
solution_path: pathlib.Path,
119119
) -> None:

tool/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ EXTRA_DIST = \
1212

1313

1414
mypy: ${script_files}
15-
${MYPY} ${srcdir}
15+
${MYPY} ${MYPY_OPTS} ${srcdir}
1616

1717
format: ${script_files}
1818
${BLACK} ${srcdir}

tool/make_character_property_map.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
import pathlib
88
import re
99
import sys
10-
from typing import List, Optional
10+
from typing import Optional
1111

1212

13-
def main(args: List[str]) -> None:
13+
def main(args: list[str]) -> None:
1414
"""The main function.
1515
1616
Args:
@@ -22,16 +22,16 @@ def main(args: List[str]) -> None:
2222
file=sys.stderr,
2323
)
2424
sys.exit(0)
25-
east_asian_width_map: List[str] = _load_file(pathlib.Path(args[0]), "N")
26-
emoji_data_map: List[str] = _load_file(pathlib.Path(args[1]), "N")
27-
grapheme_map: List[str] = _load_file(pathlib.Path(args[2]), "Other")
25+
east_asian_width_map: list[str] = _load_file(pathlib.Path(args[0]), "N")
26+
emoji_data_map: list[str] = _load_file(pathlib.Path(args[1]), "N")
27+
grapheme_map: list[str] = _load_file(pathlib.Path(args[2]), "Other")
2828
_save_file(
2929
pathlib.Path(args[3]), east_asian_width_map, emoji_data_map, grapheme_map
3030
)
3131

3232

33-
def _load_file(path: pathlib.Path, default_value: str) -> List[str]:
34-
map: List[str] = [default_value for code in range(0x110000)]
33+
def _load_file(path: pathlib.Path, default_value: str) -> list[str]:
34+
map: list[str] = [default_value for code in range(0x110000)]
3535
with path.open(mode="r", encoding="UTF-8") as stream:
3636
for line in stream:
3737
line = _remove_comment(line)
@@ -64,9 +64,9 @@ def _remove_comment(line: str) -> str:
6464

6565
def _save_file(
6666
path: pathlib.Path,
67-
east_asian_width_map: List[str],
68-
emoji_data_map: List[str],
69-
grapheme_map: List[str],
67+
east_asian_width_map: list[str],
68+
emoji_data_map: list[str],
69+
grapheme_map: list[str],
7070
) -> None:
7171
with path.open(mode="w", newline="\r\n", encoding="UTF-8") as stream:
7272
previous_value: str = ""

tool/make_character_property_map_cpp.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66

77
import pathlib
88
import sys
9-
from typing import List
109

1110

12-
def main(args: List[str]) -> None:
11+
def main(args: list[str]) -> None:
1312
"""The main function.
1413
1514
Args:
@@ -21,13 +20,13 @@ def main(args: List[str]) -> None:
2120
file=sys.stderr,
2221
)
2322
sys.exit(0)
24-
elements: List[str] = _load_file(pathlib.Path(args[0]))
23+
elements: list[str] = _load_file(pathlib.Path(args[0]))
2524
content: str = _make_cpp_source(elements)
2625
_save_file(pathlib.Path(args[1]), content)
2726

2827

29-
def _load_file(path: pathlib.Path) -> List[str]:
30-
elements: List[str] = []
28+
def _load_file(path: pathlib.Path) -> list[str]:
29+
elements: list[str] = []
3130
with path.open(mode="r") as stream:
3231
for line in stream:
3332
line = line.rstrip("\r\n")
@@ -106,7 +105,7 @@ def _to_grapheme_break_property(symbol: str) -> str:
106105
raise RuntimeError("Unknown grapheme: {}".format(symbol))
107106

108107

109-
def _make_cpp_source(elements: List[str]) -> str:
108+
def _make_cpp_source(elements: list[str]) -> str:
110109
content: str = """/*! \\file
111110
\\brief A character property map.
112111

0 commit comments

Comments
 (0)