Debian Codegraph @

testing/web-platform/tests/tools/metadata/meta/schema.py

raw
1 from dataclasses import dataclass
2 from typing import Any, ClassVar, Dict, List, Optional, Set
3
4 from ..schema import SchemaValue, validate_dict
5
6 """
7 YAML filename for meta files
8 """
9 META_YML_FILENAME = "META.yml"
10
11 @dataclass
12 class MetaFile():
13 """documented structure of META files.
14 Reference: https://github.com/web-platform-tests/wpt/pull/18434
15 """
16
17 """a link to the specification covered by the tests in the directory"""
18 spec: Optional[str] = None
19 """a list of GitHub account username belonging to people who are notified when pull requests
20 modify files in the directory
21 """
22 suggested_reviewers: Optional[List[str]] = None
23
24 _optional_keys: ClassVar[Set[str]] = {"spec", "suggested_reviewers"}
25
26 def __init__(self, obj: Dict[str, Any]):
27 validate_dict(obj, optional_keys=MetaFile._optional_keys)
28 self.spec = SchemaValue.from_union([SchemaValue.from_str, SchemaValue.from_none], obj.get("spec"))
29 self.suggested_reviewers = SchemaValue.from_union(
30 [lambda x: SchemaValue.from_list(SchemaValue.from_str, x), SchemaValue.from_none],
31 obj.get("suggested_reviewers"))