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)
| 78 | return '"%s"' % s.replace('\n', '\\n"\n%s"' % (' ' * depth * TABSIZE)) |
| 79 | |
| 80 | def 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 | |
| 95 | def asdl_of(name, obj): |
| 96 | if isinstance(obj, asdl.Product) or isinstance(obj, asdl.Constructor): |
no test coverage detected
searching dependent graphs…