Cleanup: include release/datafiles/ to "make check_mypy"

Also add type hints to some scripts.
This commit is contained in:
Campbell Barton
2024-01-25 09:59:29 +11:00
parent d44e09cf32
commit 8f4f4d62bc
4 changed files with 30 additions and 11 deletions

View File

@@ -8,13 +8,21 @@ import os
import subprocess
import sys
from typing import (
Dict,
Generator,
Optional,
Sequence,
Tuple,
)
def run(cmd, *, env=None):
def run(cmd: Sequence[str], *, env: Optional[Dict[str, str]] = None) -> None:
print(" ", " ".join(cmd))
subprocess.check_call(cmd, env=env)
def edit_text_file(filename, marker_begin, marker_end, content):
def edit_text_file(filename: str, marker_begin: str, marker_end: str, content: str) -> None:
with open(filename, 'r', encoding='utf-8') as f:
data = f.read()
marker_begin_index = data.find(marker_begin)
@@ -53,7 +61,7 @@ icons_blend = (
)
def names_and_time_from_path(path):
def names_and_time_from_path(path: str) -> Generator[Tuple[str, float], None, None]:
for entry in os.scandir(path):
name = entry.name
if name.endswith(".dat"):

View File

@@ -8,8 +8,16 @@ import os
import subprocess
import sys
from typing import (
Dict,
List,
Optional,
Sequence,
Tuple,
)
def run(cmd, *, env=None):
def run(cmd: Sequence[str], *, env: Optional[Dict[str, str]] = None) -> None:
print(" ", " ".join(cmd))
subprocess.check_call(cmd, env=env)
@@ -34,7 +42,7 @@ if not (inkscape_bin := os.environ.get("INKSCAPE_BIN")):
blender_bin = os.environ.get("BLENDER_BIN", "blender")
cmd = (
cmd: Tuple[str, ...] = (
inkscape_bin,
os.path.join(BASEDIR, "blender_icons.svg"),
"--export-width=602",

View File

@@ -24,17 +24,18 @@ except:
sys.stdout.write("Unable to open input %s\n" % argv[1])
sys.exit(1)
data = fpin.read().rsplit("{")[-1].split("}")[0]
data = data.replace(",", " ")
data = data.split()
data = [int(v) for v in data]
data_as_str = fpin.read().rsplit("{")[-1].split("}")[0]
data_as_str = data_as_str.replace(",", " ")
data_as_list = [int(v) for v in data_as_str.split()]
del data_as_str
if strip_byte:
# String data gets trailing byte.
last = data.pop()
last = data_as_list.pop()
assert last == 0
data = bytes(data)
data = bytes(data_as_list)
del data_as_list
dname = filename + ".ctodata"

View File

@@ -13,6 +13,7 @@ PATHS: Tuple[Tuple[str, Tuple[Any, ...], Dict[str, str]], ...] = (
("build_files/cmake/", (), {'MYPYPATH': "modules"}),
("build_files/utils/", (), {'MYPYPATH': "modules"}),
("doc/manpage/blender.1.py", (), {}),
("release/datafiles/", (), {}),
("tests/utils/", (), {}),
("tools/check_blender_release/", (), {}),
("tools/check_source/", (), {'MYPYPATH': "modules"}),
@@ -38,6 +39,7 @@ PATHS_EXCLUDE = set(
"build_files/cmake/cmake_static_check_smatch.py",
"build_files/cmake/cmake_static_check_sparse.py",
"build_files/cmake/cmake_static_check_splint.py",
"release/datafiles/blender_icons_geom.py", # Uses `bpy` too much.
"tests/utils/bl_run_operators.py", # Uses `bpy` too much.
"tests/utils/bl_run_operators_event_simulate.py", # Uses `bpy` too much.
"tools/check_blender_release/check_module_enabled.py",