From 1514dd7f51ed968a3a5733b56d7b6284276064e9 Mon Sep 17 00:00:00 2001 From: diegomarquezp Date: Wed, 15 Jan 2025 17:02:31 +0000 Subject: [PATCH] lint --- hermetic_build/common/model/gapic_inputs.py | 34 +++++++++++-------- hermetic_build/common/model/library_config.py | 2 +- .../tests/model/gapic_inputs_unit_tests.py | 4 +-- .../library_generation/cli/entry_point.py | 6 ++-- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/hermetic_build/common/model/gapic_inputs.py b/hermetic_build/common/model/gapic_inputs.py index 682569a254..3f69d7d412 100644 --- a/hermetic_build/common/model/gapic_inputs.py +++ b/hermetic_build/common/model/gapic_inputs.py @@ -146,22 +146,26 @@ def parse_build_str(build_str: str, versioned_path: str) -> GapicInputs: include_samples=include_samples, ) + def __get_lines_without_comments(target: list[str]): - """ - skips comment lines - """ - if len(target) == 0: - return [] - result = [] - for line in target[0].split("\n"): - if len(re.findall(comment_pattern, line)) != 0: - # skip lines whose first character is "#" since it's - # a comment. - continue - result.append(line) - return result - -def __parse_additional_protos(proto_library_target: list[str], gapic_library_target: list[str]) -> str: + """ + skips comment lines + """ + if len(target) == 0: + return [] + result = [] + for line in target[0].split("\n"): + if len(re.findall(comment_pattern, line)) != 0: + # skip lines whose first character is "#" since it's + # a comment. + continue + result.append(line) + return result + + +def __parse_additional_protos( + proto_library_target: list[str], gapic_library_target: list[str] +) -> str: res = [" "] lines = __get_lines_without_comments(proto_library_target) # first, parse the proto library definition diff --git a/hermetic_build/common/model/library_config.py b/hermetic_build/common/model/library_config.py index 7b4a64e6d2..4f087b1e6f 100644 --- a/hermetic_build/common/model/library_config.py +++ b/hermetic_build/common/model/library_config.py @@ -92,7 +92,7 @@ def get_folder_name(self, language: str = "java") -> str: For example, sdk-platform-java/showcase """ if self.folder_name is not None: - return self.folder_name + return self.folder_name return f"{language}-{self.get_library_name()}" def get_library_name(self) -> str: diff --git a/hermetic_build/common/tests/model/gapic_inputs_unit_tests.py b/hermetic_build/common/tests/model/gapic_inputs_unit_tests.py index 8b5f54845a..b65b1a94ea 100644 --- a/hermetic_build/common/tests/model/gapic_inputs_unit_tests.py +++ b/hermetic_build/common/tests/model/gapic_inputs_unit_tests.py @@ -26,11 +26,11 @@ class UtilitiesTest(unittest.TestCase): ), ( "BUILD_additional_protos_in_gapic.bazel", - " google/cloud/location/locations.proto google/iam/v1/iam_policy.proto" + " google/cloud/location/locations.proto google/iam/v1/iam_policy.proto", ), ( "BUILD_target_with_nested_parenthesis.bazel", - " google/cloud/location/locations.proto google/iam/v1/iam_policy.proto" + " google/cloud/location/locations.proto google/iam/v1/iam_policy.proto", ), ] ) diff --git a/hermetic_build/library_generation/cli/entry_point.py b/hermetic_build/library_generation/cli/entry_point.py index e23bebf9a8..e1b192d57a 100644 --- a/hermetic_build/library_generation/cli/entry_point.py +++ b/hermetic_build/library_generation/cli/entry_point.py @@ -133,14 +133,16 @@ def __generate_repo_impl( ) -def _needs_full_repo_generation(generation_config: GenerationConfig, includes: Optional[str]) -> bool: +def _needs_full_repo_generation( + generation_config: GenerationConfig, includes: Optional[str] +) -> bool: """ Whether you should need a full repo generation, i.e., generate all libraries in the generation configuration. If only showcase is specified, then it will return to false despite other conditions (allows overriding contains_common_protos()) """ - return (includes is None or includes.strip() != 'showcase') and ( + return (includes is None or includes.strip() != "showcase") and ( not generation_config.is_monorepo() or generation_config.contains_common_protos() )