Nymbo commited on
Commit
ecf8f3a
·
verified ·
1 Parent(s): d725810

fixing auto-generated docs for a few tools (Memory_Manager, File_System, Obsidian Vault)

Browse files
Files changed (1) hide show
  1. Modules/_docstrings.py +7 -1
Modules/_docstrings.py CHANGED
@@ -1,12 +1,18 @@
1
  from __future__ import annotations
2
 
3
  import inspect
4
- from typing import Any, Annotated, get_args, get_origin, get_type_hints
5
 
6
 
7
  def _typename(tp: Any) -> str:
8
  """Return a readable type name from a type or annotation."""
9
  try:
 
 
 
 
 
 
10
  if hasattr(tp, "__name__"):
11
  return tp.__name__ # e.g. int, str
12
  if getattr(tp, "__module__", None) and getattr(tp, "__qualname__", None):
 
1
  from __future__ import annotations
2
 
3
  import inspect
4
+ from typing import Any, Annotated, get_args, get_origin, get_type_hints, Union
5
 
6
 
7
  def _typename(tp: Any) -> str:
8
  """Return a readable type name from a type or annotation."""
9
  try:
10
+ # Unwrap Optional[T] -> T
11
+ if get_origin(tp) is Union:
12
+ args = [a for a in get_args(tp) if a is not type(None)]
13
+ if len(args) == 1:
14
+ return _typename(args[0])
15
+
16
  if hasattr(tp, "__name__"):
17
  return tp.__name__ # e.g. int, str
18
  if getattr(tp, "__module__", None) and getattr(tp, "__qualname__", None):