77
88from __future__ import annotations
99
10+ import json
1011import os
1112import re
1213from pathlib import Path
1314
1415from ts_utils .metadata import read_metadata
15- from ts_utils .paths import REQUIREMENTS_PATH , STDLIB_PATH , STUBS_PATH , TEST_CASES_DIR , TESTS_DIR , tests_path
16+ from ts_utils .paths import PYRIGHT_CONFIG , REQUIREMENTS_PATH , STDLIB_PATH , STUBS_PATH , TEST_CASES_DIR , TESTS_DIR , tests_path
1617from ts_utils .utils import (
1718 get_all_testcase_directories ,
1819 get_gitignore_spec ,
20+ json5_to_json ,
1921 parse_requirements ,
2022 parse_stdlib_versions_file ,
2123 spec_matches_path ,
@@ -173,6 +175,19 @@ def check_requirement_pins() -> None:
173175 assert str (spec ).startswith ("==" ), msg
174176
175177
178+ def check_pyright_exclude_order () -> None :
179+ """Check that 'exclude' entries in pyrightconfig.stricter.json are sorted alphabetically."""
180+ text = PYRIGHT_CONFIG .read_text (encoding = "utf-8" )
181+ text = json5_to_json (text )
182+ data = json .loads (text )
183+ exclude : list [str ] = data .get ("exclude" , [])
184+
185+ for i in range (len (exclude ) - 1 ):
186+ assert (
187+ exclude [i ].lower () <= exclude [i + 1 ].lower ()
188+ ), f"Entry '{ exclude [i ]} ' should come before '{ exclude [i + 1 ]} ' in the { PYRIGHT_CONFIG .name } exclude list"
189+
190+
176191if __name__ == "__main__" :
177192 check_versions_file ()
178193 check_metadata ()
@@ -182,3 +197,4 @@ def check_requirement_pins() -> None:
182197 check_stubs ()
183198 check_distutils ()
184199 check_test_cases ()
200+ check_pyright_exclude_order ()
0 commit comments