_signature_constraints
_extract_function(module_relative_path, function_name, package_name, verbose=False)
¶
Extract function from a module with the same name.
| PARAMETER | DESCRIPTION |
|---|---|
package_name
|
Example
TYPE:
|
module_relative_path
|
Example
TYPE:
|
function_name
|
Example
TYPE:
|
verbose
|
TYPE:
|
Source code in src/fractal_task_tools/_signature_constraints.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
_recursive_union_validation(*, name, annotation, default_value, recursion_level)
¶
Recursive function for union validation.
This function browses a tree of annotations, and validate the annotation of each node (if it is a union). Each Pydantic-model node then branches into additional nodes, while non-Pydantic-model nodes are the final node of their branch.
| PARAMETER | DESCRIPTION |
|---|---|
annotation
|
The annotation of the current node.
TYPE:
|
name
|
The name of the current node.
TYPE:
|
default_value
|
The default value for the current node.
TYPE:
|
recursion_level
|
TYPE:
|
Source code in src/fractal_task_tools/_signature_constraints.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
_validate_function_signature(function)
¶
Validate the function signature of a task.
Implement a set of checks for type hints that do not play well with the
creation of JSON Schema, see issue 399 in fractal-tasks-core and issue
65 in fractal-task-tools.
| PARAMETER | DESCRIPTION |
|---|---|
function
|
A callable function.
TYPE:
|
Source code in src/fractal_task_tools/_signature_constraints.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 | |
_validate_plain_union(*, name, annotation, default_value)
¶
Fail for known cases of invalid plain-union types.
A plain union annotation is (by construction) one for which
is_union(_type) = True. The only supported forms of plain unions
are X | None or X | None = None (or equivalent forms).
Note that Optional[X] is equivalent to X | None and thus it also gets
validated through this function.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Name of the annotation to validate.
TYPE:
|
annotation
|
Plain-union annotation to validate. Note that this may be equal to
TYPE:
|
default_value
|
Default value.param: The full
TYPE:
|
Source code in src/fractal_task_tools/_signature_constraints.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |