Skip to content

Commit e18e891

Browse files
Iacopo ColonnelliGlassOfWhiskey
authored andcommitted
Added arguments to abstract classes
1 parent 519a11e commit e18e891

File tree

2 files changed

+124
-100
lines changed

2 files changed

+124
-100
lines changed

schema_salad/metaschema.py

Lines changed: 95 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ def parser_info() -> str:
11891189

11901190
@trait
11911191
class Documented(Saveable, metaclass=ABCMeta):
1192-
pass
1192+
doc: None | Sequence[str] | str
11931193

11941194

11951195
class RecordField(Documented):
@@ -1457,9 +1457,9 @@ def __init__(
14571457
self.loadingOptions = loadingOptions
14581458
else:
14591459
self.loadingOptions = LoadingOptions()
1460-
self.doc = doc
1461-
self.name = name
1462-
self.type_ = type_
1460+
self.doc: None | Sequence[str] | str = doc
1461+
self.name: str = name
1462+
self.type_: ArraySchema | EnumSchema | Literal["null", "boolean", "int", "long", "float", "double", "string"] | MapSchema | RecordSchema | Sequence[ArraySchema | EnumSchema | Literal["null", "boolean", "int", "long", "float", "double", "string"] | MapSchema | RecordSchema | UnionSchema | str] | UnionSchema | str = type_
14631463

14641464
attrs: ClassVar[Collection[str]] = frozenset(["doc", "name", "type"])
14651465

@@ -1657,8 +1657,8 @@ def __init__(
16571657
self.loadingOptions = loadingOptions
16581658
else:
16591659
self.loadingOptions = LoadingOptions()
1660-
self.fields = fields
1661-
self.type_ = type_
1660+
self.fields: None | Sequence[RecordField] = fields
1661+
self.type_: Literal["record"] = type_
16621662

16631663
attrs: ClassVar[Collection[str]] = frozenset(["fields", "type"])
16641664

@@ -1929,9 +1929,9 @@ def __init__(
19291929
self.loadingOptions = loadingOptions
19301930
else:
19311931
self.loadingOptions = LoadingOptions()
1932-
self.name = name if name is not None else "_:" + str(_uuid__.uuid4())
1933-
self.symbols = symbols
1934-
self.type_ = type_
1932+
self.name: str = name if name is not None else "_:" + str(_uuid__.uuid4())
1933+
self.symbols: Sequence[str] = symbols
1934+
self.type_: Literal["enum"] = type_
19351935

19361936
attrs: ClassVar[Collection[str]] = frozenset(["name", "symbols", "type"])
19371937

@@ -2129,8 +2129,8 @@ def __init__(
21292129
self.loadingOptions = loadingOptions
21302130
else:
21312131
self.loadingOptions = LoadingOptions()
2132-
self.items = items
2133-
self.type_ = type_
2132+
self.items: ArraySchema | EnumSchema | Literal["null", "boolean", "int", "long", "float", "double", "string"] | MapSchema | RecordSchema | Sequence[ArraySchema | EnumSchema | Literal["null", "boolean", "int", "long", "float", "double", "string"] | MapSchema | RecordSchema | UnionSchema | str] | UnionSchema | str = items
2133+
self.type_: Literal["array"] = type_
21342134

21352135
attrs: ClassVar[Collection[str]] = frozenset(["items", "type"])
21362136

@@ -2328,8 +2328,8 @@ def __init__(
23282328
self.loadingOptions = loadingOptions
23292329
else:
23302330
self.loadingOptions = LoadingOptions()
2331-
self.type_ = type_
2332-
self.values = values
2331+
self.type_: Literal["map"] = type_
2332+
self.values: ArraySchema | EnumSchema | Literal["null", "boolean", "int", "long", "float", "double", "string"] | MapSchema | RecordSchema | Sequence[ArraySchema | EnumSchema | Literal["null", "boolean", "int", "long", "float", "double", "string"] | MapSchema | RecordSchema | UnionSchema | str] | UnionSchema | str = values
23332333

23342334
attrs: ClassVar[Collection[str]] = frozenset(["type", "values"])
23352335

@@ -2527,8 +2527,8 @@ def __init__(
25272527
self.loadingOptions = loadingOptions
25282528
else:
25292529
self.loadingOptions = LoadingOptions()
2530-
self.names = names
2531-
self.type_ = type_
2530+
self.names: ArraySchema | EnumSchema | Literal["null", "boolean", "int", "long", "float", "double", "string"] | MapSchema | RecordSchema | Sequence[ArraySchema | EnumSchema | Literal["null", "boolean", "int", "long", "float", "double", "string"] | MapSchema | RecordSchema | UnionSchema | str] | UnionSchema | str = names
2531+
self.type_: Literal["union"] = type_
25322532

25332533
attrs: ClassVar[Collection[str]] = frozenset(["names", "type"])
25342534

@@ -3248,17 +3248,17 @@ def __init__(
32483248
self.loadingOptions = loadingOptions
32493249
else:
32503250
self.loadingOptions = LoadingOptions()
3251-
self._id = _id
3252-
self._type = _type
3253-
self._container = _container
3254-
self.identity = identity
3255-
self.noLinkCheck = noLinkCheck
3256-
self.mapSubject = mapSubject
3257-
self.mapPredicate = mapPredicate
3258-
self.refScope = refScope
3259-
self.typeDSL = typeDSL
3260-
self.secondaryFilesDSL = secondaryFilesDSL
3261-
self.subscope = subscope
3251+
self._id: None | str = _id
3252+
self._type: None | str = _type
3253+
self._container: None | str = _container
3254+
self.identity: None | bool = identity
3255+
self.noLinkCheck: None | bool = noLinkCheck
3256+
self.mapSubject: None | str = mapSubject
3257+
self.mapPredicate: None | str = mapPredicate
3258+
self.refScope: None | i32 = refScope
3259+
self.typeDSL: None | bool = typeDSL
3260+
self.secondaryFilesDSL: None | bool = secondaryFilesDSL
3261+
self.subscope: None | str = subscope
32623262

32633263
attrs: ClassVar[Collection[str]] = frozenset(
32643264
[
@@ -3474,20 +3474,24 @@ def __init__(
34743474
self.loadingOptions = loadingOptions
34753475
else:
34763476
self.loadingOptions = LoadingOptions()
3477-
self.specializeFrom = specializeFrom
3478-
self.specializeTo = specializeTo
3477+
self.specializeFrom: str = specializeFrom
3478+
self.specializeTo: str = specializeTo
34793479

34803480
attrs: ClassVar[Collection[str]] = frozenset(["specializeFrom", "specializeTo"])
34813481

34823482

34833483
@trait
34843484
class NamedType(Saveable, metaclass=ABCMeta):
3485-
pass
3485+
name: str
3486+
inVocab: None | bool
34863487

34873488

34883489
@trait
34893490
class DocType(Documented, metaclass=ABCMeta):
3490-
pass
3491+
doc: None | Sequence[str] | str
3492+
docParent: None | str
3493+
docChild: None | Sequence[str] | str
3494+
docAfter: None | str
34913495

34923496

34933497
@trait
@@ -3497,7 +3501,12 @@ class SchemaDefinedType(DocType, metaclass=ABCMeta):
34973501
34983502
"""
34993503

3500-
pass
3504+
doc: None | Sequence[str] | str
3505+
docParent: None | str
3506+
docChild: None | Sequence[str] | str
3507+
docAfter: None | str
3508+
jsonldPredicate: JsonldPredicate | None | str
3509+
documentRoot: None | bool
35013510

35023511

35033512
class SaladRecordField(RecordField):
@@ -3878,11 +3887,11 @@ def __init__(
38783887
self.loadingOptions = loadingOptions
38793888
else:
38803889
self.loadingOptions = LoadingOptions()
3881-
self.doc = doc
3882-
self.name = name
3883-
self.type_ = type_
3884-
self.jsonldPredicate = jsonldPredicate
3885-
self.default = default
3890+
self.doc: None | Sequence[str] | str = doc
3891+
self.name: str = name
3892+
self.type_: ArraySchema | EnumSchema | Literal["null", "boolean", "int", "long", "float", "double", "string"] | MapSchema | RecordSchema | Sequence[ArraySchema | EnumSchema | Literal["null", "boolean", "int", "long", "float", "double", "string"] | MapSchema | RecordSchema | UnionSchema | str] | UnionSchema | str = type_
3893+
self.jsonldPredicate: JsonldPredicate | None | str = jsonldPredicate
3894+
self.default: Any | None = default
38863895

38873896
attrs: ClassVar[Collection[str]] = frozenset(
38883897
["doc", "name", "type", "jsonldPredicate", "default"]
@@ -4714,19 +4723,19 @@ def __init__(
47144723
self.loadingOptions = loadingOptions
47154724
else:
47164725
self.loadingOptions = LoadingOptions()
4717-
self.name = name
4718-
self.inVocab = inVocab
4719-
self.fields = fields
4720-
self.type_ = type_
4721-
self.doc = doc
4722-
self.docParent = docParent
4723-
self.docChild = docChild
4724-
self.docAfter = docAfter
4725-
self.jsonldPredicate = jsonldPredicate
4726-
self.documentRoot = documentRoot
4727-
self.abstract = abstract
4728-
self.extends = extends
4729-
self.specialize = specialize
4726+
self.name: str = name
4727+
self.inVocab: None | bool = inVocab
4728+
self.fields: None | Sequence[SaladRecordField] = fields
4729+
self.type_: Literal["record"] = type_
4730+
self.doc: None | Sequence[str] | str = doc
4731+
self.docParent: None | str = docParent
4732+
self.docChild: None | Sequence[str] | str = docChild
4733+
self.docAfter: None | str = docAfter
4734+
self.jsonldPredicate: JsonldPredicate | None | str = jsonldPredicate
4735+
self.documentRoot: None | bool = documentRoot
4736+
self.abstract: None | bool = abstract
4737+
self.extends: None | Sequence[str] | str = extends
4738+
self.specialize: None | Sequence[SpecializeDef] = specialize
47304739

47314740
attrs: ClassVar[Collection[str]] = frozenset(
47324741
[
@@ -5461,17 +5470,17 @@ def __init__(
54615470
self.loadingOptions = loadingOptions
54625471
else:
54635472
self.loadingOptions = LoadingOptions()
5464-
self.name = name if name is not None else "_:" + str(_uuid__.uuid4())
5465-
self.inVocab = inVocab
5466-
self.symbols = symbols
5467-
self.type_ = type_
5468-
self.doc = doc
5469-
self.docParent = docParent
5470-
self.docChild = docChild
5471-
self.docAfter = docAfter
5472-
self.jsonldPredicate = jsonldPredicate
5473-
self.documentRoot = documentRoot
5474-
self.extends = extends
5473+
self.name: str = name if name is not None else "_:" + str(_uuid__.uuid4())
5474+
self.inVocab: None | bool = inVocab
5475+
self.symbols: Sequence[str] = symbols
5476+
self.type_: Literal["enum"] = type_
5477+
self.doc: None | Sequence[str] | str = doc
5478+
self.docParent: None | str = docParent
5479+
self.docChild: None | Sequence[str] | str = docChild
5480+
self.docAfter: None | str = docAfter
5481+
self.jsonldPredicate: JsonldPredicate | None | str = jsonldPredicate
5482+
self.documentRoot: None | bool = documentRoot
5483+
self.extends: None | Sequence[str] | str = extends
54755484

54765485
attrs: ClassVar[Collection[str]] = frozenset(
54775486
[
@@ -6150,16 +6159,16 @@ def __init__(
61506159
self.loadingOptions = loadingOptions
61516160
else:
61526161
self.loadingOptions = LoadingOptions()
6153-
self.name = name
6154-
self.inVocab = inVocab
6155-
self.type_ = type_
6156-
self.values = values
6157-
self.doc = doc
6158-
self.docParent = docParent
6159-
self.docChild = docChild
6160-
self.docAfter = docAfter
6161-
self.jsonldPredicate = jsonldPredicate
6162-
self.documentRoot = documentRoot
6162+
self.name: str = name
6163+
self.inVocab: None | bool = inVocab
6164+
self.type_: Literal["map"] = type_
6165+
self.values: ArraySchema | EnumSchema | Literal["null", "boolean", "int", "long", "float", "double", "string"] | MapSchema | RecordSchema | Sequence[ArraySchema | EnumSchema | Literal["null", "boolean", "int", "long", "float", "double", "string"] | MapSchema | RecordSchema | UnionSchema | str] | UnionSchema | str = values
6166+
self.doc: None | Sequence[str] | str = doc
6167+
self.docParent: None | str = docParent
6168+
self.docChild: None | Sequence[str] | str = docChild
6169+
self.docAfter: None | str = docAfter
6170+
self.jsonldPredicate: JsonldPredicate | None | str = jsonldPredicate
6171+
self.documentRoot: None | bool = documentRoot
61636172

61646173
attrs: ClassVar[Collection[str]] = frozenset(
61656174
[
@@ -6779,15 +6788,15 @@ def __init__(
67796788
self.loadingOptions = loadingOptions
67806789
else:
67816790
self.loadingOptions = LoadingOptions()
6782-
self.name = name
6783-
self.inVocab = inVocab
6784-
self.names = names
6785-
self.type_ = type_
6786-
self.doc = doc
6787-
self.docParent = docParent
6788-
self.docChild = docChild
6789-
self.docAfter = docAfter
6790-
self.documentRoot = documentRoot
6791+
self.name: str = name
6792+
self.inVocab: None | bool = inVocab
6793+
self.names: ArraySchema | EnumSchema | Literal["null", "boolean", "int", "long", "float", "double", "string"] | MapSchema | RecordSchema | Sequence[ArraySchema | EnumSchema | Literal["null", "boolean", "int", "long", "float", "double", "string"] | MapSchema | RecordSchema | UnionSchema | str] | UnionSchema | str = names
6794+
self.type_: Literal["union"] = type_
6795+
self.doc: None | Sequence[str] | str = doc
6796+
self.docParent: None | str = docParent
6797+
self.docChild: None | Sequence[str] | str = docChild
6798+
self.docAfter: None | str = docAfter
6799+
self.documentRoot: None | bool = documentRoot
67916800

67926801
attrs: ClassVar[Collection[str]] = frozenset(
67936802
[
@@ -7294,13 +7303,13 @@ def __init__(
72947303
self.loadingOptions = loadingOptions
72957304
else:
72967305
self.loadingOptions = LoadingOptions()
7297-
self.name = name
7298-
self.inVocab = inVocab
7299-
self.doc = doc
7300-
self.docParent = docParent
7301-
self.docChild = docChild
7302-
self.docAfter = docAfter
7303-
self.type_ = type_
7306+
self.name: str = name
7307+
self.inVocab: None | bool = inVocab
7308+
self.doc: None | Sequence[str] | str = doc
7309+
self.docParent: None | str = docParent
7310+
self.docChild: None | Sequence[str] | str = docChild
7311+
self.docAfter: None | str = docAfter
7312+
self.type_: Literal["documentation"] = type_
73047313

73057314
attrs: ClassVar[Collection[str]] = frozenset(
73067315
["name", "inVocab", "doc", "docParent", "docChild", "docAfter", "type"]

0 commit comments

Comments
 (0)