MCPcopy Index your code
hub / github.com/RustPython/RustPython / is_child_of

Function is_child_of

crates/doc/generate.py:85–101  ·  view source on GitHub ↗

Whether or not an object is a child of a module. Returns ------- bool

(obj: typing.Any, module: types.ModuleType)

Source from the content-addressed store, hash-verified

83
84
85def is_child_of(obj: typing.Any, module: types.ModuleType) -> bool:
86 """
87 Whether or not an object is a child of a module.
88
89 Returns
90 -------
91 bool
92 """
93 if inspect.getmodule(obj) is module:
94 return True
95 # Some C modules (e.g. _ast) set __module__ to a different name (e.g. "ast"),
96 # causing inspect.getmodule() to return a different module object.
97 # Fall back to checking the module's namespace directly.
98 obj_name = getattr(obj, "__name__", None)
99 if obj_name is not None:
100 return module.__dict__.get(obj_name) is obj
101 return False
102
103
104def iter_modules() -> "Iterable[types.ModuleType]":

Callers 1

traverseFunction · 0.85

Calls 2

getattrFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected