MCPcopy
hub / github.com/reflex-dev/reflex / readable_name_from_component

Function readable_name_from_component

reflex/compiler/compiler.py:789–815  ·  view source on GitHub ↗

Get the readable name of a component. Args: component: The component to get the name of. Returns: The readable name of the component.

(
    component: Component | ComponentCallable,
)

Source from the content-addressed store, hash-verified

787
788
789def readable_name_from_component(
790 component: Component | ComponentCallable,
791) -> str | None:
792 """Get the readable name of a component.
793
794 Args:
795 component: The component to get the name of.
796
797 Returns:
798 The readable name of the component.
799 """
800 if isinstance(component, Component):
801 return type(component).__name__
802 if isinstance(component, (Var, int, float, str)):
803 return str(component)
804 if isinstance(component, Sequence):
805 return ", ".join(str(c) for c in component)
806 if callable(component):
807 module_name = getattr(component, "__module__", None)
808 if module_name is not None:
809 module = getmodule(component)
810 if module is not None:
811 module_name = module.__name__
812 if module_name is not None:
813 return f"{module_name}.{component.__name__}"
814 return component.__name__
815 return None
816
817
818def _modify_exception(e: Exception) -> None:

Callers 1

add_pageMethod · 0.90

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected