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

Method visit_load_literal

mypyc/ir/pprint.py:113–130  ·  view source on GitHub ↗
(self, op: LoadLiteral)

Source from the content-addressed store, hash-verified

111 return self.format("%r = <error> :: %s", op, op.type)
112
113 def visit_load_literal(self, op: LoadLiteral) -> str:
114 prefix = ""
115 # For values that have a potential unboxed representation, make
116 # it explicit that this is a Python object.
117 if isinstance(op.value, int):
118 prefix = "object "
119
120 rvalue = repr(op.value)
121 if isinstance(op.value, frozenset):
122 # We need to generate a string representation that won't vary
123 # run-to-run because sets are unordered, otherwise we may get
124 # spurious irbuild test failures.
125 #
126 # Sorting by the item's string representation is a bit of a
127 # hack, but it's stable and won't cause TypeErrors.
128 formatted_items = [repr(i) for i in sorted(op.value, key=str)]
129 rvalue = "frozenset({" + ", ".join(formatted_items) + "})"
130 return self.format("%r = %s%s", op, prefix, rvalue)
131
132 def visit_get_attr(self, op: GetAttr) -> str:
133 return self.format("%r = %s%r.%s", op, self.borrow_prefix(op), op.obj, op.attr)

Callers

nothing calls this directly

Calls 5

formatMethod · 0.95
isinstanceFunction · 0.85
reprFunction · 0.85
sortedFunction · 0.85
joinMethod · 0.45

Tested by

no test coverage detected