Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomarquezp committed Jan 15, 2025
1 parent e1c270a commit 1514dd7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
34 changes: 19 additions & 15 deletions hermetic_build/common/model/gapic_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hermetic_build/common/model/library_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions hermetic_build/common/tests/model/gapic_inputs_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
]
)
Expand Down
6 changes: 4 additions & 2 deletions hermetic_build/library_generation/cli/entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
Expand Down

0 comments on commit 1514dd7

Please sign in to comment.