MCPcopy Create free account
hub / github.com/ipython/ipython / IntegerWrapper

Class IntegerWrapper

IPython/core/tests/test_interactiveshell.py:716–732  ·  view source on GitHub ↗

Wraps all integers in a call to Integer()

Source from the content-addressed store, hash-verified

714 assert line_t == 1
715
716class IntegerWrapper(ast.NodeTransformer):
717 """Wraps all integers in a call to Integer()"""
718
719 # for Python 3.7 and earlier
720
721 # for Python 3.7 and earlier
722 def visit_Num(self, node):
723 if isinstance(node.n, int):
724 return ast.Call(func=ast.Name(id='Integer', ctx=ast.Load()),
725 args=[node], keywords=[])
726 return node
727
728 # For Python 3.8+
729 def visit_Constant(self, node):
730 if isinstance(node.value, int):
731 return self.visit_Num(node)
732 return node
733
734
735class TestAstTransform2(unittest.TestCase):

Callers 1

setUpMethod · 0.85

Calls

no outgoing calls

Tested by 1

setUpMethod · 0.68