From 40b603a17f9b6c8aca42de97aec67322c11fac56 Mon Sep 17 00:00:00 2001 From: Eric Date: Tue, 1 Aug 2023 11:03:08 -0700 Subject: [PATCH] pyright config cleanup --- .efrocachemap | 32 ++++++++++++------------- Makefile | 2 +- config/toolconfigsrc/pyrightconfig.json | 9 ------- config/toolconfigsrc/pyrightconfig.yaml | 19 +++++++++++++++ tools/efrotools/toolconfig.py | 17 +++++++++++-- 5 files changed, 51 insertions(+), 28 deletions(-) delete mode 100644 config/toolconfigsrc/pyrightconfig.json create mode 100644 config/toolconfigsrc/pyrightconfig.yaml diff --git a/.efrocachemap b/.efrocachemap index 34ca0b4a..d7b1e128 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -4076,18 +4076,18 @@ "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "42649b501212bea15f4b2f2741583339", "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "03cbedec6c8f294d7fe57a6dc64803e8", "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "37b2c536cd841b40319b0efae40471ce", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "b4744e1a3bdb8a0d38873f8c0967fbc5", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "1f67054d55541b13ca912b4d9b57f499", "build/prefab/full/mac_arm64_gui/release/ballisticakit": "5399d3f4924909ca1c0878f347e20a10", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "a3236ad2650a3f41f62148af7e6e7a6f", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "18c01fc3b664bb30bd2e5b6ad635b5f3", "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "58559f7512a300586b8141591a21564e", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "b7b82f5429cf87c82e0c6514a07c3815", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "cec05c9cf3882d00ba27b81696d95d1e", "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "8e98e2bb1d7d9fa34f873fd2b7d82138", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "161e1603f3649b1ba926fcbabee1c976", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "c215407232dbf0166d9980c1dae780b6", "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "49107effdf5c1ee5a0533251a99f9f6a", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "fcdabb98d5c4aeef8b68e9e2e9cc15f6", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "96c90979b26eb1a385f7d3448a10ada8", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "c8e32e52d2a3e6663e36cf615d321af2", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "d60bd48af61f8d0110abc9acc26440c8", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "8731458bc07c5a9ecea1c2ac46b5b96c", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "e51c409b2f1ca6433f96e3b10615a914", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "b3d961223dc84f6805613790d1e2c267", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "1cadf9af171902a4984658c624a42142", "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "85ba4e81a1f7ae2cff4b1355eb49904f", "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "498921f7eb2afd327d4b900cb70e31f9", "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "85ba4e81a1f7ae2cff4b1355eb49904f", @@ -4104,14 +4104,14 @@ "build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "0ab638b6602610bdaf432e3cc2464080", "build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "92394eb19387c363471ce134ac9e6a1b", "build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "0ab638b6602610bdaf432e3cc2464080", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "4df33d360a5d4e3f702a10f136cb6319", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "c446dbc526736768fb0eedb2ce7bc418", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "c2113c6e8eab2ba598fab7168da3b6c8", - "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "77fe6d2ee487ab510dd0b6f85a890053", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "1bfbadf7ff4a1b8fe7e13ac0f9f613d5", - "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "ef0a86c9189b07f9c3bccf43b90d3b0b", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "b9900d7e0d8dbca5a23870a98bd703ec", - "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "251ece0eb9f9f7d25070a505054a6026", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "aa2d3f27999da77b4ad584df0707d8c0", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "2d134738e7ea8d7751ebae3df834806e", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "451c1d7295846fcad90b649fc574ee0e", + "build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "3e910b8da4a13dbcdde7955bbde17abb", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "987b68e1e4b4e89bd73d5014735318d6", + "build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "520f2b3e9c7ae15954589ce148dc1506", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "d02da070911bac71d7dbb4afc7a93e6a", + "build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "629d285dfe041d4237e14d140ac70482", "src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c", "src/assets/ba_data/python/babase/_mgen/enums.py": "f8cd3af311ac63147882590123b78318", "src/ballistica/base/mgen/pyembed/binding_base.inc": "eeddad968b176000e31c65be6206a2bc", diff --git a/Makefile b/Makefile index 9fc5eb31..262f21ae 100644 --- a/Makefile +++ b/Makefile @@ -1193,7 +1193,7 @@ ENV_SRC = tools/pcommand tools/batools/build.py .mypy.ini: config/toolconfigsrc/mypy.ini $(TOOL_CFG_SRC) @$(TOOL_CFG_INST) $< $@ -.pyrightconfig.json: config/toolconfigsrc/pyrightconfig.json $(TOOL_CFG_SRC) +.pyrightconfig.json: config/toolconfigsrc/pyrightconfig.yaml $(TOOL_CFG_SRC) @$(TOOL_CFG_INST) $< $@ .pycheckers: config/toolconfigsrc/pycheckers $(TOOL_CFG_SRC) diff --git a/config/toolconfigsrc/pyrightconfig.json b/config/toolconfigsrc/pyrightconfig.json deleted file mode 100644 index 4a4f9044..00000000 --- a/config/toolconfigsrc/pyrightconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "include": [ - "tools" - ], - "typeCheckingMode": "basic", - "reportMissingTypeStubs": true, - "stubPath": "src/stubs", - "pythonPlatform": "Linux" -} diff --git a/config/toolconfigsrc/pyrightconfig.yaml b/config/toolconfigsrc/pyrightconfig.yaml new file mode 100644 index 00000000..cd067498 --- /dev/null +++ b/config/toolconfigsrc/pyrightconfig.yaml @@ -0,0 +1,19 @@ +# Pyright's actual config is a json file but we're using yaml here so we can +# include lovely comments (yaml is a superset of json) and then we bake it down +# into a json file. +{ + + # For now I'm listing explicit things here. Once we get everything passing we + # can autogenerate the include list like we do for other checkers. + "include": [ + "tools" + ], + + # Ideally we should get to 'strict' for everying if we want to consider + # leaning on this as much as we do mypy. But + "typeCheckingMode": "basic", + + "reportMissingTypeStubs": true, + "stubPath": "src/stubs", + "pythonPlatform": "Linux" +} diff --git a/tools/efrotools/toolconfig.py b/tools/efrotools/toolconfig.py index 6688892d..bf9bd5db 100644 --- a/tools/efrotools/toolconfig.py +++ b/tools/efrotools/toolconfig.py @@ -22,8 +22,21 @@ def install_tool_config(projroot: Path, src: Path, dst: Path) -> None: """Install a config.""" print(f'Creating tool config: {Clr.BLD}{dst}{Clr.RST}') - with src.open(encoding='utf-8') as infile: - cfg = infile.read() + # Special case: if we've got a src .yaml and a dst .json, convert. + # This can be handy to add annotations/etc. in the src which isn't + # possible with json. + if src.suffix == '.yaml' and dst.suffix == '.json': + import yaml + import json + + with src.open(encoding='utf-8') as infile: + contents = yaml.safe_load(infile.read()) + cfg = json.dumps(contents, indent=2, sort_keys=True) + + # In normal cases we just push the source file straight through. + else: + with src.open(encoding='utf-8') as infile: + cfg = infile.read() # Some substitutions, etc. cfg = _filter_tool_config(projroot, cfg)