Nima Mashhadi M. Reza
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
2 additions and
5 deletions
-
fastapi/encoders.py
|
|
@ -16,12 +16,9 @@ DictIntStrAny = Dict[Union[int, str], Any] |
|
|
|
def generate_encoders_by_class_tuples( |
|
|
|
type_encoder_map: Dict[Any, Callable] |
|
|
|
) -> Dict[Callable, Tuple]: |
|
|
|
encoders_by_classes: Dict[Callable, List] = defaultdict(list) |
|
|
|
encoders_by_class_tuples: Dict[Callable, Tuple] = defaultdict(tuple) |
|
|
|
for type_, encoder in type_encoder_map.items(): |
|
|
|
encoders_by_classes[encoder].append(type_) |
|
|
|
encoders_by_class_tuples: Dict[Callable, Tuple] = {} |
|
|
|
for encoder, classes in encoders_by_classes.items(): |
|
|
|
encoders_by_class_tuples[encoder] = tuple(classes) |
|
|
|
encoders_by_class_tuples[encoder] += (type_,) |
|
|
|
return encoders_by_class_tuples |
|
|
|
|
|
|
|
|
|
|
|