gradio_utils.py 426 B

123456789101112
  1. def type_to_string(_type: type) -> str:
  2. """Gets the string representation of a type.
  3. THe original type can be derived from the returned string representation through
  4. pydoc.locate().
  5. """
  6. if _type.__module__ == "typing":
  7. return f"{_type.__module__}.{_type._name}"
  8. elif _type.__module__ == "builtins":
  9. return _type.__name__
  10. else:
  11. return f"{_type.__module__}.{_type.__name__}"