Skip to content

Commit

Permalink
Ran black to fix format.
Browse files Browse the repository at this point in the history
  • Loading branch information
Laren-AWS committed Apr 8, 2024
1 parent a61f4b8 commit f2184b7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
6 changes: 5 additions & 1 deletion aws_doc_sdk_examples_tools/doc_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@

# from os import glob

from .metadata import Example, parse as parse_examples, validate_no_duplicate_api_examples
from .metadata import (
Example,
parse as parse_examples,
validate_no_duplicate_api_examples,
)
from .metadata_errors import MetadataErrors, MetadataError
from .metadata_validator import validate_metadata
from .project_validator import check_files, verify_sample_files, ValidationConfig
Expand Down
17 changes: 12 additions & 5 deletions aws_doc_sdk_examples_tools/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,11 @@ def from_yaml(
for action in actions:
svc_actions.append(f"{svc}:{action}")
if len(svc_actions) != 1:
errors.append(metadata_errors.APIMustHaveOneServiceOneAction(svc_actions=", ".join(svc_actions)))
errors.append(
metadata_errors.APIMustHaveOneServiceOneAction(
svc_actions=", ".join(svc_actions)
)
)

service_main = yaml.get("service_main", None)
if service_main is not None and service_main not in services:
Expand Down Expand Up @@ -411,10 +415,13 @@ def validate_no_duplicate_api_examples(examples: List[Example], errors: Metadata
svc_action_map[f"{service}:{action}"].append(example)
for svc_action, ex_items in svc_action_map.items():
if len(ex_items) > 1:
errors.append(metadata_errors.DuplicateAPIExample(
id=", ".join({ex_item.id for ex_item in ex_items}),
file=", ".join({ex_item.file for ex_item in ex_items}),
svc_action=svc_action))
errors.append(
metadata_errors.DuplicateAPIExample(
id=", ".join({ex_item.id for ex_item in ex_items}),
file=", ".join({ex_item.file for ex_item in ex_items}),
svc_action=svc_action,
)
)


def main():
Expand Down
2 changes: 2 additions & 0 deletions aws_doc_sdk_examples_tools/metadata_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def message(self) -> str:
def __str__(self):
return f"{self.prefix()} {self.message()}"


@dataclass
class MetadataParseError(MetadataError):
id: Optional[str] = None
Expand Down Expand Up @@ -267,6 +268,7 @@ class DuplicateService(MetadataParseError):
def message(self):
return f"service {self.services} listed more than once"


@dataclass
class DuplicateExample(MetadataParseError):
other_file: str = ""
Expand Down

0 comments on commit f2184b7

Please sign in to comment.