Skip to content

Commit 004e65e

Browse files
committed
fix: show full Optional[T] type in help instead of just Optional
Use repr() instead of __qualname__ to get full type representation. Fixes #508
1 parent 716bbc2 commit 004e65e

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

fire/helptext.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -524,13 +524,9 @@ def _GetArgType(arg, spec):
524524
"""
525525
if arg in spec.annotations:
526526
arg_type = spec.annotations[arg]
527-
try:
528-
return arg_type.__qualname__
529-
except AttributeError:
530-
# Some typing objects, such as typing.Union do not have either a __name__
531-
# or __qualname__ attribute.
532-
# repr(typing.Union[int, str]) will return ': typing.Union[int, str]'
533-
return repr(arg_type)
527+
# Use repr() to get full type representation including generic args (e.g., Optional[str])
528+
# This fixes the bug where __qualname__ returns just "Optional" instead of "Optional[str]"
529+
return repr(arg_type)
534530
return ''
535531

536532

0 commit comments

Comments
 (0)