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

Method visit_Constant

mypy/fastparse.py:1628–1649  ·  view source on GitHub ↗
(self, n: ast3.Constant)

Source from the content-addressed store, hash-verified

1626
1627 # Constant(object value)
1628 def visit_Constant(self, n: ast3.Constant) -> Any:
1629 val = n.value
1630 e: Any = None
1631 if val is None:
1632 e = NameExpr("None")
1633 elif isinstance(val, str):
1634 e = StrExpr(val)
1635 elif isinstance(val, bytes):
1636 e = BytesExpr(bytes_to_human_readable_repr(val))
1637 elif isinstance(val, bool): # Must check before int!
1638 e = NameExpr(str(val))
1639 elif isinstance(val, int):
1640 e = IntExpr(val)
1641 elif isinstance(val, float):
1642 e = FloatExpr(val)
1643 elif isinstance(val, complex):
1644 e = ComplexExpr(val)
1645 elif val is Ellipsis:
1646 e = EllipsisExpr()
1647 else:
1648 raise RuntimeError("Constant not implemented for " + str(type(val)))
1649 return self.set_line(e, n)
1650
1651 # JoinedStr(expr* values)
1652 def visit_JoinedStr(self, n: ast3.JoinedStr) -> Expression:

Callers

nothing calls this directly

Calls 13

set_lineMethod · 0.95
NameExprClass · 0.90
StrExprClass · 0.90
BytesExprClass · 0.90
IntExprClass · 0.90
FloatExprClass · 0.90
ComplexExprClass · 0.90
EllipsisExprClass · 0.90
isinstanceFunction · 0.85
strClass · 0.85
RuntimeErrorClass · 0.85

Tested by

no test coverage detected