1313PROJECT_ROOT = Path (subprocess .getoutput ("git rev-parse --show-toplevel" )) # noqa: S605
1414TIMEOUTS_FILE = PROJECT_ROOT / "tests" / "resources" / "timeouts.yaml"
1515
16- Seconds = float
17- DEFAULT_TIMEOUT : Seconds = 10
16+ DEFAULT_TIMEOUT_SECONDS : float = 10
1817
19- IS_FILE_VALID = bool
18+ IS_FILE_VALID = IS_FILE_INVALID = bool
2019
2120
2221def main (full_file_paths : Iterable [str ]) -> bool :
2322 return validate_unique_names () and all (map (validate_qmod , full_file_paths ))
2423
2524
26- def validate_qmod (file_path : str , automatically_add_timeout : bool = True ) -> bool :
25+ def validate_qmod (
26+ file_path : str , automatically_add_timeout : bool = True
27+ ) -> IS_FILE_VALID :
2728 file_name = os .path .basename (file_path )
28- with open (file_path ) as f :
29- file_content = f .read ()
3029
3130 errors = []
3231
33- if not _forbid_dash_in_file_name (file_name ):
32+ if _does_contain_dash_in_file_name (file_name ):
3433 errors .append (
3534 "Dash (-) is not allowed in file named. please use underscore (_)"
3635 )
@@ -43,20 +42,14 @@ def validate_qmod(file_path: str, automatically_add_timeout: bool = True) -> boo
4342 errors .append ("File is missing timeout in the timeouts.yaml file." )
4443
4544 if errors :
46- print (f"file `{ file_path } ` has error:" )
47- for error in errors :
48- print (f'\t "{ error } "' )
45+ spacing = "\n \t " # f-string cannot include backslash
46+ print (f"file `{ file_path } ` has error:{ spacing } { spacing .join (errors )} " )
4947
50- is_ok = not errors
51- return is_ok
52-
53-
54- def _demand_internal_prefix (file_name : str ) -> IS_FILE_VALID :
55- return file_name .startswith ("internal_" )
48+ return not errors
5649
5750
58- def _forbid_dash_in_file_name (file_name : str ) -> IS_FILE_VALID :
59- return not ( "-" in file_name )
51+ def _does_contain_dash_in_file_name (file_name : str ) -> IS_FILE_INVALID :
52+ return "-" in file_name
6053
6154
6255def _is_file_in_timeouts (file_name : str ) -> IS_FILE_VALID :
@@ -70,7 +63,7 @@ def _add_file_to_timeouts(file_name: str) -> None:
7063 with TIMEOUTS_FILE .open ("r" ) as f :
7164 timeouts = yaml .safe_load (f )
7265
73- timeouts [file_name ] = DEFAULT_TIMEOUT
66+ timeouts [file_name ] = DEFAULT_TIMEOUT_SECONDS
7467
7568 with TIMEOUTS_FILE .open ("w" ) as f :
7669 yaml .dump (timeouts , f , sort_keys = True )
0 commit comments