MCPcopy Index your code
hub / github.com/python/mypy / get_edge_candidates

Function get_edge_candidates

mypy/server/objgraph.py:39–56  ·  view source on GitHub ↗
(o: object)

Source from the content-addressed store, hash-verified

37
38
39def get_edge_candidates(o: object) -> Iterator[tuple[object, object]]:
40 # use getattr because mypyc expects dict, not mappingproxy
41 if "__getattribute__" in getattr(type(o), "__dict__"): # noqa: B009
42 return
43 if type(o) not in COLLECTION_TYPE_BLACKLIST:
44 for attr in dir(o):
45 try:
46 if attr not in ATTR_BLACKLIST and hasattr(o, attr) and not isproperty(o, attr):
47 e = getattr(o, attr)
48 if type(e) not in ATOMIC_TYPE_BLACKLIST:
49 yield attr, e
50 except AssertionError:
51 pass
52 if isinstance(o, Mapping):
53 yield from o.items()
54 elif isinstance(o, Iterable) and not isinstance(o, str):
55 for i, e in enumerate(o):
56 yield i, e
57
58
59def get_edges(o: object) -> Iterator[tuple[object, object]]:

Callers 1

get_edgesFunction · 0.85

Calls 7

getattrFunction · 0.85
typeClass · 0.85
hasattrFunction · 0.85
ispropertyFunction · 0.85
isinstanceFunction · 0.85
enumerateFunction · 0.85
itemsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…