Skip to content

Commit

Permalink
Merge pull request #16 from ltrojan/union-custom-types
Browse files Browse the repository at this point in the history
chili/decoder.py: pass extra_decoders to build_type_decoder
  • Loading branch information
dkraczkowski authored Aug 11, 2023
2 parents 229f05a + afcb47c commit af54626
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion chili/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,10 @@ def build_type_decoder(a_type: Type, extra_decoders: TypeDecoders = None, module
if origin_type is Union:
type_args = get_type_args(a_type)
if len(type_args) == 2 and type_args[-1] is type(None):
return OptionalTypeDecoder(build_type_decoder(type_args[0])) # type: ignore
return OptionalTypeDecoder(
build_type_decoder(
a_type=type_args[0],
extra_decoders=extra_decoders)) # type: ignore
return UnionDecoder(type_args)

if isinstance(a_type, typing.ForwardRef) and module is not None:
Expand Down

0 comments on commit af54626

Please sign in to comment.