From cfc645901fa08978410a85b6312ae81ddc382d8a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Oct 2024 13:18:36 +1100 Subject: [PATCH] Cleanup: use type hints for discover_nodes.py --- source/blender/nodes/intern/discover_nodes.py | 10 +++++----- tools/check_source/check_mypy_config.py | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/source/blender/nodes/intern/discover_nodes.py b/source/blender/nodes/intern/discover_nodes.py index ed7d404a790..6b17e2a5229 100644 --- a/source/blender/nodes/intern/discover_nodes.py +++ b/source/blender/nodes/intern/discover_nodes.py @@ -22,7 +22,7 @@ import re import sys -def filepath_is_older(filepath_test, filepath_compare): +def filepath_is_older(filepath_test: str, filepath_compare: tuple[str, ...]) -> bool: import stat mtime = os.stat(filepath_test)[stat.ST_MTIME] for filepath_other in filepath_compare: @@ -52,9 +52,9 @@ source_cc_files = [ macro_name = "NOD_REGISTER_NODE" discover_suffix = "_discover" -include_lines = [] -decl_lines = [] -func_lines = [] +include_lines: list[str] = [] +decl_lines: list[str] = [] +func_lines: list[str] = [] # Add forward declaration to avoid warning. func_lines.append(f"void {function_to_generate}();") @@ -75,7 +75,7 @@ for path in source_cc_files: code = fh.read() # Keeps track of the current name-space we're in. - namespace_parts = [] + namespace_parts: list[str] = [] for match in re_all_compiled.finditer(code): if entered_namespace := match.group(2): diff --git a/tools/check_source/check_mypy_config.py b/tools/check_source/check_mypy_config.py index c3d808fb6c8..c5bd6498a03 100644 --- a/tools/check_source/check_mypy_config.py +++ b/tools/check_source/check_mypy_config.py @@ -15,6 +15,7 @@ PATHS: tuple[tuple[str, tuple[Any, ...], dict[str, str]], ...] = ( ("scripts/modules/_bpy_internal/extensions/junction_module.py", (), {}), ("scripts/modules/_bpy_internal/extensions/wheel_manager.py", (), {}), ("scripts/modules/_bpy_internal/freedesktop.py", (), {}), + ("source/blender/nodes/intern/discover_nodes.py", (), {}), ("tools/check_blender_release/", (), {}), ("tools/check_docs/", (), {}), ("tools/check_source/", (), {'MYPYPATH': "modules"}),