Skip to content

Commit 5fe71db

Browse files
committed
Follow conventions
1 parent 9d2f50b commit 5fe71db

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

.internal/pre_commit_tools/notebook_pre_commit_collection.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,12 @@
1515

1616
DEFAULT_TIMEOUT_SECONDS: float = 20
1717

18-
IS_FILE_VALID = IS_FILE_INVALID = bool
19-
2018

2119
def main(full_file_paths: Iterable[str]) -> bool:
22-
return validate_unique_names() and all(map(validate_notebook, full_file_paths))
20+
return validate_unique_names() and all(map(is_valid_notebook, full_file_paths))
2321

2422

25-
def validate_notebook(
26-
file_path: str, automatically_add_timeout: bool = True
27-
) -> IS_FILE_VALID:
23+
def is_valid_notebook(file_path: str, automatically_add_timeout: bool = True) -> bool:
2824
file_name = os.path.basename(file_path)
2925

3026
errors = []
@@ -43,16 +39,16 @@ def validate_notebook(
4339

4440
if errors:
4541
spacing = "\n\t" # f-string cannot include backslash
46-
print(f"file `{file_path}` has error:{spacing}{spacing.join(errors)}")
42+
print(f"File `{file_path}` has error(s):{spacing}{spacing.join(errors)}")
4743

4844
return not errors
4945

5046

51-
def _does_contain_dash_in_file_name(file_name: str) -> IS_FILE_INVALID:
47+
def _does_contain_dash_in_file_name(file_name: str) -> bool:
5248
return "-" in file_name
5349

5450

55-
def _is_file_in_timeouts(file_name: str) -> IS_FILE_VALID:
51+
def _is_file_in_timeouts(file_name: str) -> bool:
5652
with TIMEOUTS_FILE.open("r") as f:
5753
timeouts = yaml.safe_load(f)
5854

@@ -76,7 +72,7 @@ def validate_unique_names() -> bool:
7672
duplicate_names = [name for name, count in Counter(base_names).items() if count > 1]
7773

7874
if duplicate_names:
79-
print(f"notebooks with duplicate names found: {duplicate_names}")
75+
print(f"Notebooks with duplicate names found: {duplicate_names}")
8076

8177
is_ok = not duplicate_names
8278
return is_ok

.internal/pre_commit_tools/qmod_pre_commit_collection.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,12 @@
1515

1616
DEFAULT_TIMEOUT_SECONDS: float = 10
1717

18-
IS_FILE_VALID = IS_FILE_INVALID = bool
19-
2018

2119
def main(full_file_paths: Iterable[str]) -> bool:
22-
return validate_unique_names() and all(map(validate_qmod, full_file_paths))
20+
return validate_unique_names() and all(map(is_valid_qmod, full_file_paths))
2321

2422

25-
def validate_qmod(
26-
file_path: str, automatically_add_timeout: bool = True
27-
) -> IS_FILE_VALID:
23+
def is_valid_qmod(file_path: str, automatically_add_timeout: bool = True) -> bool:
2824
file_name = os.path.basename(file_path)
2925

3026
errors = []
@@ -43,16 +39,16 @@ def validate_qmod(
4339

4440
if errors:
4541
spacing = "\n\t" # f-string cannot include backslash
46-
print(f"file `{file_path}` has error:{spacing}{spacing.join(errors)}")
42+
print(f"File `{file_path}` has error(s):{spacing}{spacing.join(errors)}")
4743

4844
return not errors
4945

5046

51-
def _does_contain_dash_in_file_name(file_name: str) -> IS_FILE_INVALID:
47+
def _does_contain_dash_in_file_name(file_name: str) -> bool:
5248
return "-" in file_name
5349

5450

55-
def _is_file_in_timeouts(file_name: str) -> IS_FILE_VALID:
51+
def _is_file_in_timeouts(file_name: str) -> bool:
5652
with TIMEOUTS_FILE.open("r") as f:
5753
timeouts = yaml.safe_load(f)
5854

@@ -78,7 +74,7 @@ def validate_unique_names() -> bool:
7874
duplicate_names = [name for name, count in Counter(base_names).items() if count > 1]
7975

8076
if duplicate_names:
81-
print(f"qmods with duplicate names found: {duplicate_names}")
77+
print(f"Qmods with duplicate names found: {duplicate_names}")
8278

8379
is_ok = not duplicate_names
8480
return is_ok

0 commit comments

Comments
 (0)