MCPcopy Index your code
hub / github.com/python/cpython / is_simple

Function is_simple

Parser/asdl_c.py:80–93  ·  view source on GitHub ↗

Return True if a sum is a simple. A sum is simple if its types have no fields and itself doesn't have any attributes. Instances of these types are cached at C level, and they act like singletons when propagating parser generated nodes into Python level, e.g. unaryop = Invert | N

(sum_type)

Source from the content-addressed store, hash-verified

78 return '"%s"' % s.replace('\n', '\\n"\n%s"' % (' ' * depth * TABSIZE))
79
80def is_simple(sum_type):
81 """Return True if a sum is a simple.
82
83 A sum is simple if its types have no fields and itself
84 doesn't have any attributes. Instances of these types are
85 cached at C level, and they act like singletons when propagating
86 parser generated nodes into Python level, e.g.
87 unaryop = Invert | Not | UAdd | USub
88 """
89
90 return not (
91 sum_type.attributes or
92 any(constructor.fields for constructor in sum_type.types)
93 )
94
95def asdl_of(name, obj):
96 if isinstance(obj, asdl.Product) or isinstance(obj, asdl.Constructor):

Callers 11

asdl_ofFunction · 0.85
visitSumMethod · 0.85
visitSumMethod · 0.85
visitSumMethod · 0.85
visitSumMethod · 0.85
visitSumMethod · 0.85
visitSumMethod · 0.85
visitSumMethod · 0.85
visitSumMethod · 0.85
visitSumMethod · 0.85
visitSumMethod · 0.85

Calls 1

anyFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…