Skip to content

Commit 1039b57

Browse files
committed
Updated comments and streamlined 'extract_base_type' function
1 parent 6590ee7 commit 1039b57

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/murfey/cli/generate_route_manifest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ def extract_base_type(annotation):
3939
The unwrapped base type, or the original annotation if no unambiguous base
4040
type can be determined.
4141
"""
42-
# Unwrap Annotated
42+
# Unwrap Annotated type annotations
4343
if get_origin(annotation) is Annotated:
4444
annotation = get_args(annotation)[0]
4545

46-
# Unwrap Optional / Union:param
47-
origin = get_origin(annotation)
48-
if origin is Union:
46+
# Unwrap and return single-type Optional type annotations
47+
if get_origin(annotation) is Union:
4948
args = [a for a in get_args(annotation) if a is not type(None)]
5049
if len(args) == 1:
5150
return args[0]
5251

52+
# Return complex multi-type annotations or simple unpacked ones
5353
return annotation
5454

5555

0 commit comments

Comments
 (0)