Transform the given `data` based on the annotations provided in `type_`. Note: this function only looks at `Annotated` types that contain `PropertyInfo` metadata.
(key: str, type_: type)
| 129 | |
| 130 | |
| 131 | def _maybe_transform_key(key: str, type_: type) -> str: |
| 132 | """Transform the given `data` based on the annotations provided in `type_`. |
| 133 | |
| 134 | Note: this function only looks at `Annotated` types that contain `PropertyInfo` metadata. |
| 135 | """ |
| 136 | annotated_type = _get_annotated_type(type_) |
| 137 | if annotated_type is None: |
| 138 | # no `Annotated` definition for this type, no transformation needed |
| 139 | return key |
| 140 | |
| 141 | # ignore the first argument as it is the actual type |
| 142 | annotations = get_args(annotated_type)[1:] |
| 143 | for annotation in annotations: |
| 144 | if isinstance(annotation, PropertyInfo) and annotation.alias is not None: |
| 145 | return annotation.alias |
| 146 | |
| 147 | return key |
| 148 | |
| 149 | |
| 150 | def _no_transform_needed(annotation: type) -> bool: |
no test coverage detected