liminal-orm 2.0.2__py3-none-any.whl → 2.0.3a1__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.
- liminal/validation/__init__.py +30 -36
- {liminal_orm-2.0.2.dist-info → liminal_orm-2.0.3a1.dist-info}/METADATA +1 -1
- {liminal_orm-2.0.2.dist-info → liminal_orm-2.0.3a1.dist-info}/RECORD +6 -6
- {liminal_orm-2.0.2.dist-info → liminal_orm-2.0.3a1.dist-info}/LICENSE.md +0 -0
- {liminal_orm-2.0.2.dist-info → liminal_orm-2.0.3a1.dist-info}/WHEEL +0 -0
- {liminal_orm-2.0.2.dist-info → liminal_orm-2.0.3a1.dist-info}/entry_points.txt +0 -0
liminal/validation/__init__.py
CHANGED
@@ -101,21 +101,36 @@ class BenchlingValidatorReport(BaseModel):
|
|
101
101
|
)
|
102
102
|
|
103
103
|
|
104
|
-
def
|
105
|
-
func: Callable[[type["BenchlingBaseModel"]], BenchlingValidatorReport | None]
|
106
|
-
|
107
|
-
|
104
|
+
def liminal_validator(
|
105
|
+
func: Callable[[type["BenchlingBaseModel"]], BenchlingValidatorReport | None]
|
106
|
+
| None = None,
|
107
|
+
*,
|
108
|
+
validator_level: ValidationSeverity = ValidationSeverity.LOW,
|
109
|
+
validator_name: str | None = None,
|
108
110
|
) -> Callable:
|
109
|
-
"""
|
110
|
-
|
111
|
-
|
112
|
-
if not params or params[0].name != "self" or len(params) > 1:
|
113
|
-
raise TypeError(
|
114
|
-
"Validator must be defined in a schema class, where the only argument to this validator must be 'self'."
|
115
|
-
)
|
111
|
+
"""A decorator for a function that validates a Benchling entity, defined on a schema class.
|
112
|
+
Can be used with or without parameters. Wraps around any exceptions raised by the validator function,
|
113
|
+
and returns a BenchlingValidatorReport.
|
116
114
|
|
117
|
-
|
118
|
-
|
115
|
+
Parameters
|
116
|
+
----------
|
117
|
+
validator_level: ValidationSeverity
|
118
|
+
The severity level of the validation report. Defaults to ValidationSeverity.LOW.
|
119
|
+
validator_name: str | None
|
120
|
+
The name of the validator. Defaults to the PascalCase version of the function name.
|
121
|
+
"""
|
122
|
+
if func is None:
|
123
|
+
return partial(
|
124
|
+
liminal_validator,
|
125
|
+
validator_level=validator_level,
|
126
|
+
validator_name=validator_name,
|
127
|
+
)
|
128
|
+
elif not isinstance(
|
129
|
+
func, Callable[[["BenchlingBaseModel"]], BenchlingValidatorReport | None]
|
130
|
+
):
|
131
|
+
raise ValueError(
|
132
|
+
"Parameters passed to liminal_validator must be keyword arguments, not positional arguments."
|
133
|
+
)
|
119
134
|
|
120
135
|
@wraps(func)
|
121
136
|
def wrapper(self: type["BenchlingBaseModel"]) -> BenchlingValidatorReport:
|
@@ -129,36 +144,15 @@ def _liminal_decorator(
|
|
129
144
|
valid=False,
|
130
145
|
level=validator_level,
|
131
146
|
entity=self,
|
132
|
-
validator_name=validator_name,
|
147
|
+
validator_name=validator_name or pascalize(func.__name__),
|
133
148
|
message=str(e),
|
134
149
|
)
|
135
150
|
return BenchlingValidatorReport.create_validation_report(
|
136
151
|
valid=True,
|
137
152
|
level=validator_level,
|
138
153
|
entity=self,
|
139
|
-
validator_name=validator_name,
|
154
|
+
validator_name=validator_name or pascalize(func.__name__),
|
140
155
|
)
|
141
156
|
|
142
157
|
setattr(wrapper, "_is_liminal_validator", True)
|
143
158
|
return wrapper
|
144
|
-
|
145
|
-
|
146
|
-
def liminal_validator(
|
147
|
-
validator_level: ValidationSeverity = ValidationSeverity.LOW,
|
148
|
-
validator_name: str | None = None,
|
149
|
-
) -> Callable:
|
150
|
-
"""A decorator for a function that validates a Benchling entity, defined on a schema class.
|
151
|
-
Wraps around any exceptions raised by the validator function, and returns a BenchlingValidatorReport.
|
152
|
-
|
153
|
-
Parameters
|
154
|
-
----------
|
155
|
-
validator_level: ValidationSeverity
|
156
|
-
The severity level of the validation report. Defaults to ValidationSeverity.LOW.
|
157
|
-
validator_name: str | None =
|
158
|
-
The name of the validator. Defaults to the PascalCase version of the function name.
|
159
|
-
"""
|
160
|
-
return partial(
|
161
|
-
_liminal_decorator,
|
162
|
-
validator_level=validator_level,
|
163
|
-
validator_name=validator_name,
|
164
|
-
)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: liminal-orm
|
3
|
-
Version: 2.0.
|
3
|
+
Version: 2.0.3a1
|
4
4
|
Summary: An ORM and toolkit that builds on top of Benchling's platform to keep your schemas and downstream code dependencies in sync.
|
5
5
|
Home-page: https://github.com/dynotx/liminal-orm
|
6
6
|
Author: DynoTx Open Source
|
@@ -59,10 +59,10 @@ liminal/tests/from benchling_sdk.py,sha256=CjRUHFB3iaa4rUPLGOqDiBq5EPKldm-Fd8aQQ
|
|
59
59
|
liminal/tests/test_dropdown_compare.py,sha256=yHB0ovQlBLRu8-qYkqIPd8VtYEOmOft_93FQM86g_z8,8198
|
60
60
|
liminal/tests/test_entity_schema_compare.py,sha256=-26Bu5eYIuHRswB5kYjGDo5Wed5LUWjm1e6IRI1Q-lE,18952
|
61
61
|
liminal/utils.py,sha256=radRtRsZmCiNblMvxOX1DH0rcO5TR09kFlp6OONIPBU,2951
|
62
|
-
liminal/validation/__init__.py,sha256=
|
62
|
+
liminal/validation/__init__.py,sha256=1EOF2cQ_MQu_K7eQrBgsaP3GVp5AalKRD9NNE0px-0Y,5558
|
63
63
|
liminal/validation/validation_severity.py,sha256=ib03PTZCQHcbBDc01v4gJF53YtA-ANY6QSFnhTV-FbU,259
|
64
|
-
liminal_orm-2.0.
|
65
|
-
liminal_orm-2.0.
|
66
|
-
liminal_orm-2.0.
|
67
|
-
liminal_orm-2.0.
|
68
|
-
liminal_orm-2.0.
|
64
|
+
liminal_orm-2.0.3a1.dist-info/LICENSE.md,sha256=oVA877F_D1AV44dpjsv4f-4k690uNGApX1EtzOo3T8U,11353
|
65
|
+
liminal_orm-2.0.3a1.dist-info/METADATA,sha256=s0aHimEXa07bwDqvmNH8fdLQ0pmLcL3ZNg0kpk1m3r8,11034
|
66
|
+
liminal_orm-2.0.3a1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
67
|
+
liminal_orm-2.0.3a1.dist-info/entry_points.txt,sha256=atIrU63rrzH81dWC2sjUbFLlc5FWMmYRdMxXEWexIZA,47
|
68
|
+
liminal_orm-2.0.3a1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|