morphir-python 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- morphir/__init__.py +14 -0
- morphir/ir/__init__.py +110 -0
- morphir/ir/access_controlled.py +15 -0
- morphir/ir/decorations.py +19 -0
- morphir/ir/diagnostics.py +105 -0
- morphir/ir/distribution.py +21 -0
- morphir/ir/document.py +37 -0
- morphir/ir/documented.py +11 -0
- morphir/ir/format_version.py +483 -0
- morphir/ir/fqname.py +9 -0
- morphir/ir/json.py +11 -0
- morphir/ir/literal.py +25 -0
- morphir/ir/meta.py +11 -0
- morphir/ir/migrate.py +1267 -0
- morphir/ir/module.py +17 -0
- morphir/ir/name.py +27 -0
- morphir/ir/package.py +15 -0
- morphir/ir/path.py +25 -0
- morphir/ir/qname.py +9 -0
- morphir/ir/ref.py +17 -0
- morphir/ir/type.py +37 -0
- morphir/ir/type_constraints.py +33 -0
- morphir/ir/type_def.py +19 -0
- morphir/ir/type_spec.py +25 -0
- morphir/ir/v3/__init__.py +64 -0
- morphir/ir/v3/_legacy_value.py +201 -0
- morphir/ir/v3/access_controlled.py +31 -0
- morphir/ir/v3/codec.py +1275 -0
- morphir/ir/v3/codec_v1.py +491 -0
- morphir/ir/v3/codec_v2.py +187 -0
- morphir/ir/v3/distribution.py +42 -0
- morphir/ir/v3/documented.py +13 -0
- morphir/ir/v3/fqname.py +30 -0
- morphir/ir/v3/literal.py +46 -0
- morphir/ir/v3/module.py +32 -0
- morphir/ir/v3/name.py +42 -0
- morphir/ir/v3/package.py +23 -0
- morphir/ir/v3/path.py +29 -0
- morphir/ir/v3/qname.py +16 -0
- morphir/ir/v3/type.py +126 -0
- morphir/ir/v3/value.py +235 -0
- morphir/ir/v4/__init__.py +160 -0
- morphir/ir/v4/access_controlled.py +17 -0
- morphir/ir/v4/annotation.py +75 -0
- morphir/ir/v4/codec.py +2161 -0
- morphir/ir/v4/decorations.py +88 -0
- morphir/ir/v4/distribution.py +56 -0
- morphir/ir/v4/document.py +69 -0
- morphir/ir/v4/documented.py +10 -0
- morphir/ir/v4/fqname.py +69 -0
- morphir/ir/v4/incompleteness.py +78 -0
- morphir/ir/v4/json.py +103 -0
- morphir/ir/v4/literal.py +51 -0
- morphir/ir/v4/meta.py +27 -0
- morphir/ir/v4/module.py +30 -0
- morphir/ir/v4/name.py +69 -0
- morphir/ir/v4/package.py +19 -0
- morphir/ir/v4/path.py +50 -0
- morphir/ir/v4/qname.py +34 -0
- morphir/ir/v4/ref.py +35 -0
- morphir/ir/v4/type.py +140 -0
- morphir/ir/v4/type_constraints.py +91 -0
- morphir/ir/v4/type_def.py +38 -0
- morphir/ir/v4/type_spec.py +64 -0
- morphir/ir/v4/value.py +480 -0
- morphir/ir/value.py +81 -0
- morphir/py.typed +0 -0
- morphir/sdk/__init__.py +110 -0
- morphir/sdk/_compare.py +187 -0
- morphir/sdk/aggregate.py +421 -0
- morphir/sdk/basics.py +504 -0
- morphir/sdk/char.py +110 -0
- morphir/sdk/decimal.py +311 -0
- morphir/sdk/dict.py +336 -0
- morphir/sdk/instant.py +118 -0
- morphir/sdk/int.py +86 -0
- morphir/sdk/key.py +522 -0
- morphir/sdk/list.py +356 -0
- morphir/sdk/local_date.py +436 -0
- morphir/sdk/local_time.py +267 -0
- morphir/sdk/maybe.py +135 -0
- morphir/sdk/number.py +237 -0
- morphir/sdk/regex.py +287 -0
- morphir/sdk/result.py +162 -0
- morphir/sdk/result_list.py +169 -0
- morphir/sdk/rule.py +103 -0
- morphir/sdk/set.py +214 -0
- morphir/sdk/stateful_app.py +49 -0
- morphir/sdk/string.py +427 -0
- morphir/sdk/tuple.py +43 -0
- morphir/sdk/uuid.py +209 -0
- morphir_python-0.0.1.dist-info/METADATA +269 -0
- morphir_python-0.0.1.dist-info/RECORD +99 -0
- morphir_python-0.0.1.dist-info/WHEEL +4 -0
- morphir_python-0.0.1.dist-info/entry_points.txt +2 -0
- morphir_python-0.0.1.dist-info/licenses/LICENSE +201 -0
- morphir_tools/__init__.py +13 -0
- morphir_tools/cli.py +223 -0
- morphir_tools/py.typed +0 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"""Morphir IR v4 model (draft upstream).
|
|
2
|
+
|
|
3
|
+
IR v4 is not frozen in finos/morphir. The JSON codec in `morphir.ir.v4.codec` is a
|
|
4
|
+
draft pinned to finos/morphir commit efa36060.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from . import annotation, incompleteness, module, package
|
|
8
|
+
from .access_controlled import AccessControlled
|
|
9
|
+
from .annotation import (
|
|
10
|
+
Annotation,
|
|
11
|
+
AnnotationArgument,
|
|
12
|
+
CompactAnnotation,
|
|
13
|
+
NamedArgument,
|
|
14
|
+
PositionalArgument,
|
|
15
|
+
StructuredAnnotation,
|
|
16
|
+
)
|
|
17
|
+
from .decorations import (
|
|
18
|
+
DecorationFormat,
|
|
19
|
+
DecorationValuesFile,
|
|
20
|
+
LayerManifest,
|
|
21
|
+
SchemaRef,
|
|
22
|
+
)
|
|
23
|
+
from .distribution import (
|
|
24
|
+
ApplicationDistribution,
|
|
25
|
+
Distribution,
|
|
26
|
+
EntryPoint,
|
|
27
|
+
EntryPointKind,
|
|
28
|
+
LibraryDistribution,
|
|
29
|
+
PackageInfo,
|
|
30
|
+
SpecsDistribution,
|
|
31
|
+
)
|
|
32
|
+
from .document import (
|
|
33
|
+
DocArray,
|
|
34
|
+
DocBool,
|
|
35
|
+
DocFloat,
|
|
36
|
+
DocInt,
|
|
37
|
+
DocNull,
|
|
38
|
+
DocObject,
|
|
39
|
+
DocString,
|
|
40
|
+
Document,
|
|
41
|
+
)
|
|
42
|
+
from .documented import Documented
|
|
43
|
+
from .fqname import FQName
|
|
44
|
+
from .incompleteness import (
|
|
45
|
+
DeletedDuringRefactor,
|
|
46
|
+
DraftIncompleteness,
|
|
47
|
+
HoleIncompleteness,
|
|
48
|
+
HoleReason,
|
|
49
|
+
Incompleteness,
|
|
50
|
+
TypeMismatch,
|
|
51
|
+
UnresolvedReference,
|
|
52
|
+
)
|
|
53
|
+
from .literal import (
|
|
54
|
+
BoolLiteral,
|
|
55
|
+
CharLiteral,
|
|
56
|
+
DecimalLiteral,
|
|
57
|
+
FloatLiteral,
|
|
58
|
+
IntegerLiteral,
|
|
59
|
+
Literal,
|
|
60
|
+
StringLiteral,
|
|
61
|
+
)
|
|
62
|
+
from .meta import FileMeta, SourceRange
|
|
63
|
+
from .name import Name
|
|
64
|
+
from .path import Path
|
|
65
|
+
from .qname import QName
|
|
66
|
+
from .ref import DefRef, FileWithDefs, PointerRef, Ref
|
|
67
|
+
from .type import Field, Type, TypeAttributes
|
|
68
|
+
from .type_constraints import TypeConstraints
|
|
69
|
+
from .type_def import Definition as TypeDefinition
|
|
70
|
+
from .type_spec import Specification as TypeSpecification
|
|
71
|
+
from .value import Definition as ValueDefinition
|
|
72
|
+
from .value import (
|
|
73
|
+
ExternalBinding,
|
|
74
|
+
ExternalBody,
|
|
75
|
+
IncompleteBody,
|
|
76
|
+
NativeBody,
|
|
77
|
+
NativeHint,
|
|
78
|
+
NativeInfo,
|
|
79
|
+
Pattern,
|
|
80
|
+
Value,
|
|
81
|
+
ValueAttributes,
|
|
82
|
+
ValueDefinitionBody,
|
|
83
|
+
)
|
|
84
|
+
from .value import Specification as ValueSpecification
|
|
85
|
+
|
|
86
|
+
__all__ = [
|
|
87
|
+
"AccessControlled",
|
|
88
|
+
"Annotation",
|
|
89
|
+
"AnnotationArgument",
|
|
90
|
+
"ApplicationDistribution",
|
|
91
|
+
"BoolLiteral",
|
|
92
|
+
"CharLiteral",
|
|
93
|
+
"CompactAnnotation",
|
|
94
|
+
"DecimalLiteral",
|
|
95
|
+
"DecorationFormat",
|
|
96
|
+
"DecorationValuesFile",
|
|
97
|
+
"DefRef",
|
|
98
|
+
"DeletedDuringRefactor",
|
|
99
|
+
"Distribution",
|
|
100
|
+
"DocArray",
|
|
101
|
+
"DocBool",
|
|
102
|
+
"DocFloat",
|
|
103
|
+
"DocInt",
|
|
104
|
+
"DocNull",
|
|
105
|
+
"DocObject",
|
|
106
|
+
"DocString",
|
|
107
|
+
"Document",
|
|
108
|
+
"Documented",
|
|
109
|
+
"DraftIncompleteness",
|
|
110
|
+
"EntryPoint",
|
|
111
|
+
"EntryPointKind",
|
|
112
|
+
"ExternalBinding",
|
|
113
|
+
"ExternalBody",
|
|
114
|
+
"FQName",
|
|
115
|
+
"Field",
|
|
116
|
+
"FileMeta",
|
|
117
|
+
"FileWithDefs",
|
|
118
|
+
"FloatLiteral",
|
|
119
|
+
"HoleIncompleteness",
|
|
120
|
+
"HoleReason",
|
|
121
|
+
"IncompleteBody",
|
|
122
|
+
"Incompleteness",
|
|
123
|
+
"IntegerLiteral",
|
|
124
|
+
"LayerManifest",
|
|
125
|
+
"LibraryDistribution",
|
|
126
|
+
"Literal",
|
|
127
|
+
"Name",
|
|
128
|
+
"NamedArgument",
|
|
129
|
+
"NativeBody",
|
|
130
|
+
"NativeHint",
|
|
131
|
+
"NativeInfo",
|
|
132
|
+
"PackageInfo",
|
|
133
|
+
"Path",
|
|
134
|
+
"Pattern",
|
|
135
|
+
"PointerRef",
|
|
136
|
+
"PositionalArgument",
|
|
137
|
+
"QName",
|
|
138
|
+
"Ref",
|
|
139
|
+
"SchemaRef",
|
|
140
|
+
"SourceRange",
|
|
141
|
+
"SpecsDistribution",
|
|
142
|
+
"StringLiteral",
|
|
143
|
+
"StructuredAnnotation",
|
|
144
|
+
"Type",
|
|
145
|
+
"TypeAttributes",
|
|
146
|
+
"TypeConstraints",
|
|
147
|
+
"TypeDefinition",
|
|
148
|
+
"TypeMismatch",
|
|
149
|
+
"TypeSpecification",
|
|
150
|
+
"UnresolvedReference",
|
|
151
|
+
"Value",
|
|
152
|
+
"ValueAttributes",
|
|
153
|
+
"ValueDefinition",
|
|
154
|
+
"ValueDefinitionBody",
|
|
155
|
+
"ValueSpecification",
|
|
156
|
+
"annotation",
|
|
157
|
+
"incompleteness",
|
|
158
|
+
"module",
|
|
159
|
+
"package",
|
|
160
|
+
]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Generic, TypeVar, Union
|
|
3
|
+
|
|
4
|
+
T = TypeVar("T")
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclass(frozen=True)
|
|
8
|
+
class Public(Generic[T]):
|
|
9
|
+
value: T
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass(frozen=True)
|
|
13
|
+
class Private(Generic[T]):
|
|
14
|
+
value: T
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
AccessControlled = Union[Public[T], Private[T]]
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Annotations on v4 specifications.
|
|
2
|
+
|
|
3
|
+
Follows the finos/morphir v4 schema (``Annotation``, ``AnnotationArgument``) at
|
|
4
|
+
the pinned commit and the morphir-rust v4 model. An annotation keeps the form it
|
|
5
|
+
was written in, because the kit writes an argument-less structured annotation as
|
|
6
|
+
an object and a compact one as a string. Annotations belong to specifications,
|
|
7
|
+
the public face; definitions carry none.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from dataclasses import dataclass, field
|
|
13
|
+
from typing import Union
|
|
14
|
+
|
|
15
|
+
from .fqname import FQName
|
|
16
|
+
from .name import Name
|
|
17
|
+
from .value import Value
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass(frozen=True)
|
|
21
|
+
class PositionalArgument:
|
|
22
|
+
"""An annotation argument written on its own.
|
|
23
|
+
|
|
24
|
+
Attributes:
|
|
25
|
+
value: The argument expression.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
value: Value
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass(frozen=True)
|
|
32
|
+
class NamedArgument:
|
|
33
|
+
"""An annotation argument written under the name it answers to.
|
|
34
|
+
|
|
35
|
+
Attributes:
|
|
36
|
+
name: The parameter name.
|
|
37
|
+
value: The argument expression.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
name: Name
|
|
41
|
+
value: Value
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
AnnotationArgument = Union[PositionalArgument, NamedArgument]
|
|
45
|
+
"""A positional or named annotation argument."""
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass(frozen=True)
|
|
49
|
+
class CompactAnnotation:
|
|
50
|
+
"""The compact spelling: ``"pkg:mod#name"`` or ``"pkg:mod#name:text"``.
|
|
51
|
+
|
|
52
|
+
Attributes:
|
|
53
|
+
name: The annotation type.
|
|
54
|
+
text: The free text after the first colon after ``#``, if any.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
name: FQName
|
|
58
|
+
text: str | None = None
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@dataclass(frozen=True)
|
|
62
|
+
class StructuredAnnotation:
|
|
63
|
+
"""The structured spelling: ``{"name": ..., "arguments": [...]}``.
|
|
64
|
+
|
|
65
|
+
Attributes:
|
|
66
|
+
name: The annotation type.
|
|
67
|
+
arguments: Positional and named arguments, in order.
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
name: FQName
|
|
71
|
+
arguments: list[AnnotationArgument] = field(default_factory=list)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
Annotation = Union[CompactAnnotation, StructuredAnnotation]
|
|
75
|
+
"""An annotation on a module, type or value specification."""
|