mirror of
https://projects.blender.org/blender/blender.git
synced 2025-01-22 07:22:12 -05:00
mypy: update checker to support specific files overlapping directories
This allows single files to use different settings to other files in the same directory. Add check_unused_defines.py.
This commit is contained in:
parent
273f48cd53
commit
8701ccc6d8
2 changed files with 9 additions and 1 deletions
|
@ -68,6 +68,10 @@ def main() -> None:
|
|||
# Fixed location, so change the current working directory doesn't create cache everywhere.
|
||||
cache_dir = os.path.join(os.getcwd(), ".mypy_cache")
|
||||
|
||||
# Allow files which are listed explicitly to override files that are included as part of a directory.
|
||||
# Needed when files need their own arguments and/or environment.
|
||||
files_explicitly_listed: set[str] = {f for f, _extra_args, _extra_env in PATHS}
|
||||
|
||||
if os.path.samefile(sys.argv[-1], __file__):
|
||||
paths = path_expand_with_args(PATHS, is_source)
|
||||
else:
|
||||
|
@ -79,6 +83,8 @@ def main() -> None:
|
|||
for f, extra_args, extra_env in paths:
|
||||
if f in PATHS_EXCLUDE:
|
||||
continue
|
||||
if f in files_explicitly_listed:
|
||||
continue
|
||||
|
||||
if not extra_args:
|
||||
extra_args = ()
|
||||
|
|
|
@ -9,6 +9,8 @@ from typing import (
|
|||
|
||||
# Notes:
|
||||
# - Most tests in `tests/python` use `bpy` enough that it's simpler to list the scripts that *are* type checked.
|
||||
# - References individual files which are also included in a directory are supported
|
||||
# without checking those files twice. This is needed to allow those files to use their own settings.
|
||||
PATHS: tuple[tuple[str, tuple[Any, ...], dict[str, str]], ...] = (
|
||||
("build_files/cmake/", (), {'MYPYPATH': "modules"}),
|
||||
("build_files/utils/", (), {'MYPYPATH': "modules"}),
|
||||
|
@ -23,6 +25,7 @@ PATHS: tuple[tuple[str, tuple[Any, ...], dict[str, str]], ...] = (
|
|||
("tools/check_blender_release/", (), {}),
|
||||
("tools/check_docs/", (), {}),
|
||||
("tools/check_source/", (), {'MYPYPATH': "modules"}),
|
||||
("tools/check_source/check_unused_defines.py", (), {'MYPYPATH': "../utils_maintenance/modules"}),
|
||||
("tools/config/", (), {}),
|
||||
("tools/triage/", (), {}),
|
||||
("tools/utils/", (), {}),
|
||||
|
@ -56,7 +59,6 @@ PATHS_EXCLUDE = set(
|
|||
"tools/check_blender_release/scripts/requests_basic_access.py",
|
||||
"tools/check_blender_release/scripts/requests_import.py",
|
||||
"tools/check_source/check_descriptions.py",
|
||||
"tools/check_source/check_unused_defines.py",
|
||||
"tools/utils/blend2json.py",
|
||||
"tools/utils/blender_keyconfig_export_permutations.py",
|
||||
"tools/utils/blender_merge_format_changes.py",
|
||||
|
|
Loading…
Reference in a new issue