MCPcopy
hub / github.com/marimo-team/marimo / explore_module

Function explore_module

tests/utils.py:42–80  ·  view source on GitHub ↗

Recursively explore a module and print all public exported items. Args: module: The module or object to explore indent: Current indentation level (for pretty printing) visited: Set[int] = set()

(
    module: Any, indent: int = 0, visited: set[int] | None = None
)

Source from the content-addressed store, hash-verified

40
41
42def explore_module(
43 module: Any, indent: int = 0, visited: set[int] | None = None
44) -> list[str]:
45 """
46 Recursively explore a module and print all public exported items.
47
48 Args:
49 module: The module or object to explore
50 indent: Current indentation level (for pretty printing)
51 visited: Set[int] = set()
52 """
53 if visited is None:
54 visited = set()
55
56 # Skip if we've already visited this object
57 if id(module) in visited:
58 return []
59
60 visited.add(id(module))
61
62 results: list[str] = []
63 # Get all attributes of the module
64 for name, obj in inspect.getmembers(module):
65 # Skip private/special attributes (starting with _)
66 if name.startswith("_"):
67 continue
68
69 # Create indentation string
70 indent_str = " " * indent
71
72 # Print the current item
73 results.append(f"{indent_str}{name}")
74
75 # Recursively explore if it's a module, class, or other container type
76 if inspect.ismodule(obj) and obj.__name__.startswith(module.__name__):
77 # Only recurse into submodules of the original module
78 results.extend(explore_module(obj, indent + 1, visited))
79
80 return results

Callers 2

test_apiFunction · 0.90
test_internal_apiFunction · 0.90

Calls 2

addMethod · 0.45
appendMethod · 0.45

Tested by 2

test_apiFunction · 0.72
test_internal_apiFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…