Skip to content

Commit 999aa52

Browse files
authored
Allow arbitary strings in sdk_version owner to capture FeedbackSim or similar. (#155)
1 parent 2309157 commit 999aa52

4 files changed

Lines changed: 14 additions & 42 deletions

File tree

aws_doc_sdk_examples_tools/metadata.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ class Person:
3333
alias: str
3434

3535

36-
@dataclass
37-
class FeedbackCti:
38-
category: str
39-
type: str
40-
item: str
41-
42-
4336
@dataclass
4437
class Excerpt:
4538
description: Optional[str]
@@ -75,7 +68,7 @@ class Version:
7568
# List of people who have contributed to this example.
7669
authors: List[Person] = field(default_factory=list)
7770
# Feedback and maintenance owner. Primarily for internal use.
78-
owner: Optional[FeedbackCti] = field(default=None)
71+
owner: Optional[str] = field(default=None)
7972
# Link to the original tributary that contributed this version.
8073
source: Optional[Url] = field(default=None)
8174

aws_doc_sdk_examples_tools/metadata_errors.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ def message(self):
175175
return f"missing field {self.field}"
176176

177177

178+
@dataclass
179+
class InvalidFieldType(FieldError):
180+
reason: str = "unknown"
181+
182+
def message(self):
183+
return f"invalid field type {self.field} ({self.reason})"
184+
185+
178186
@dataclass
179187
class AwsNotEntity(FieldError):
180188
check_err: str = ""
@@ -241,16 +249,6 @@ def message(self):
241249
return "lists version which is not listed in sdks.yaml."
242250

243251

244-
@dataclass
245-
class InvalidFeedbackCti(SdkVersionError):
246-
feedback_cti: str = ""
247-
248-
def message(self):
249-
return (
250-
f"has feedback CTI that is missing at least one field: {self.feedback_cti}"
251-
)
252-
253-
254252
@dataclass
255253
class InvalidGithubLink(SdkVersionError):
256254
link: str = ""

aws_doc_sdk_examples_tools/metadata_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,12 +749,12 @@ def test_verify_load_successful():
749749
name="None",
750750
alias="author@example.com",
751751
),
752-
metadata_errors.InvalidFeedbackCti(
752+
metadata_errors.InvalidFieldType(
753753
file=ERRORS_METADATA_PATH,
754754
id="sqs_InvalidOwner",
755755
language="Java",
756756
sdk_version=2,
757-
feedback_cti="AWS|Documentation|None",
757+
reason="must be string",
758758
),
759759
],
760760
[

aws_doc_sdk_examples_tools/yaml_mapper.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
from typing import Dict, Set, Tuple, Any, List, Optional, Union
5-
from pathlib import Path
65
from .metadata import (
76
Example,
87
Language,
98
Url,
109
Version,
1110
Excerpt,
1211
Person,
13-
FeedbackCti,
1412
)
1513
from .sdks import Sdk
1614
from .services import Service
@@ -220,23 +218,6 @@ def person_from_yaml(
220218
return Person(name, alias)
221219

222220

223-
def feedback_cti_from_yaml(
224-
yaml: Union[None, Dict[str, Optional[str]]]
225-
) -> Optional[Union[FeedbackCti, MetadataParseError]]:
226-
if yaml is None:
227-
return None
228-
category = yaml.get("category")
229-
type = yaml.get("type")
230-
item = yaml.get("item")
231-
232-
if category is None or type is None or item is None:
233-
return metadata_errors.InvalidFeedbackCti(
234-
feedback_cti="|".join([str(category), str(type), str(item)])
235-
)
236-
237-
return FeedbackCti(category, type, item)
238-
239-
240221
def version_from_yaml(
241222
yaml: Dict[str, Any],
242223
cross_content_blocks: Set[str],
@@ -284,9 +265,9 @@ def version_from_yaml(
284265
elif author is not None:
285266
errors.append(author)
286267

287-
owner = feedback_cti_from_yaml(yaml.get("owner"))
288-
if owner is not None and not isinstance(owner, FeedbackCti):
289-
errors.append(owner)
268+
owner = yaml.get("owner")
269+
if owner and not isinstance(owner, str):
270+
errors.append(metadata_errors.InvalidFieldType(reason="must be string"))
290271
owner = None
291272

292273
add_services = parse_services(yaml.get("add_services", {}), errors)

0 commit comments

Comments
 (0)