Remove type comments in run_project_tests.py

pull/12333/head
Tristan Partin 1 year ago committed by Eli Schwartz
parent 88b337b77c
commit 1991ad8706
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 2
      mesonbuild/cmake/common.py
  2. 24
      run_project_tests.py
  3. 4
      tools/cmake2meson.py
  4. 2
      unittests/internaltests.py

@ -209,7 +209,7 @@ class CMakeTarget:
self.link_lang_flags = _flags_to_list(data.get('linkLanguageFlags', ''))
# self.link_path = Path(data.get('linkPath', ''))
self.type: str = data.get('type', 'EXECUTABLE')
# self.is_generator_provided = data.get('isGeneratorProvided', False) # type: bool
# self.is_generator_provided: bool = data.get('isGeneratorProvided', False)
self.files: T.List[CMakeFileGroup] = []
for i in data.get('fileGroups', []):

@ -134,11 +134,11 @@ class InstalledFile:
self.path = raw['file']
self.typ = raw['type']
self.platform = raw.get('platform', None)
self.language = raw.get('language', 'c') # type: str
self.language = raw.get('language', 'c')
version = raw.get('version', '') # type: str
version = raw.get('version', '')
if version:
self.version = version.split('.') # type: T.List[str]
self.version = version.split('.')
else:
# split on '' will return [''], we want an empty list though
self.version = []
@ -280,9 +280,9 @@ class TestDef:
self.args = args
self.skip = skip
self.env = os.environ.copy()
self.installed_files = [] # type: T.List[InstalledFile]
self.do_not_set_opts = [] # type: T.List[str]
self.stdout = [] # type: T.List[T.Dict[str, str]]
self.installed_files: T.List[InstalledFile] = []
self.do_not_set_opts: T.List[str] = []
self.stdout: T.List[T.Dict[str, str]] = []
self.skip_category = skip_category
self.skip_expected = False
@ -399,7 +399,7 @@ def platform_fix_name(fname: str, canonical_compiler: str, env: environment.Envi
def validate_install(test: TestDef, installdir: Path, env: environment.Environment) -> str:
ret_msg = ''
expected_raw = [] # type: T.List[Path]
expected_raw: T.List[Path] = []
for i in test.installed_files:
try:
expected_raw += i.get_paths(host_c_compiler, env, installdir)
@ -828,7 +828,7 @@ def load_test_json(t: TestDef, stdout_mandatory: bool, skip_category: bool = Fal
test_def = json.loads(test_def_file.read_text(encoding='utf-8'))
# Handle additional environment variables
env = {} # type: T.Dict[str, str]
env: T.Dict[str, str] = {}
if 'env' in test_def:
assert isinstance(test_def['env'], dict)
env = test_def['env']
@ -838,7 +838,7 @@ def load_test_json(t: TestDef, stdout_mandatory: bool, skip_category: bool = Fal
env[key] = val
# Handle installed files
installed = [] # type: T.List[InstalledFile]
installed: T.List[InstalledFile] = []
if 'installed' in test_def:
installed = [InstalledFile(x) for x in test_def['installed']]
@ -848,7 +848,7 @@ def load_test_json(t: TestDef, stdout_mandatory: bool, skip_category: bool = Fal
raise RuntimeError(f"{test_def_file} must contain a non-empty stdout key")
# Handle the do_not_set_opts list
do_not_set_opts = test_def.get('do_not_set_opts', []) # type: T.List[str]
do_not_set_opts: T.List[str] = test_def.get('do_not_set_opts', [])
(t.skip, t.skip_expected) = _skip_keys(test_def)
@ -872,12 +872,12 @@ def load_test_json(t: TestDef, stdout_mandatory: bool, skip_category: bool = Fal
new_opt_list: T.List[T.List[T.Tuple[str, str, bool, bool]]]
# 'matrix; entry is present, so build multiple tests from matrix definition
opt_list = [] # type: T.List[T.List[T.Tuple[str, str, bool, bool]]]
opt_list: T.List[T.List[T.Tuple[str, str, bool, bool]]] = []
matrix = test_def['matrix']
assert "options" in matrix
for key, val in matrix["options"].items():
assert isinstance(val, list)
tmp_opts = [] # type: T.List[T.Tuple[str, str, bool, bool]]
tmp_opts: T.List[T.Tuple[str, str, bool, bool]] = []
for i in val:
assert isinstance(i, dict)
assert "val" in i

@ -119,7 +119,7 @@ class Parser:
return Statement(cur.value, args)
def arguments(self) -> T.List[T.Union[Token, T.Any]]:
args = [] # type: T.List[T.Union[Token, T.Any]]
args: T.List[T.Union[Token, T.Any]] = []
if self.accept('lparen'):
args.append(self.arguments())
self.expect('rparen')
@ -159,7 +159,7 @@ class Converter:
self.cmake_root = Path(cmake_root).expanduser()
self.indent_unit = ' '
self.indent_level = 0
self.options = [] # type: T.List[tuple]
self.options: T.List[T.Tuple[str, str, T.Optional[str]]] = []
def convert_args(self, args: T.List[Token], as_array: bool = True) -> str:
res = []

@ -1020,7 +1020,7 @@ class InternalTests(unittest.TestCase):
schema = json.loads(Path('data/test.schema.json').read_text(encoding='utf-8'))
errors = [] # type: T.Tuple[str, Exception]
errors: T.List[T.Tuple[Path, Exception]] = []
for p in Path('test cases').glob('**/test.json'):
try:
validate(json.loads(p.read_text(encoding='utf-8')), schema=schema)

Loading…
Cancel
Save