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

Method quiet

IPython/core/displayhook.py:84–103  ·  view source on GitHub ↗

Should we silence the display hook because of ';'?

(self)

Source from the content-addressed store, hash-verified

82 pass
83
84 def quiet(self):
85 """Should we silence the display hook because of ';'?"""
86 # do not print output if input ends in ';'
87
88 try:
89 cell = self.shell.history_manager.input_hist_parsed[-1]
90 except IndexError:
91 # some uses of ipshellembed may fail here
92 return False
93
94 sio = _io.StringIO(cell)
95 tokens = list(tokenize.generate_tokens(sio.readline))
96
97 for token in reversed(tokens):
98 if token[0] in (tokenize.ENDMARKER, tokenize.NL, tokenize.NEWLINE, tokenize.COMMENT):
99 continue
100 if (token[0] == tokenize.OP) and (token[1] == ';'):
101 return True
102 else:
103 return False
104
105 def start_displayhook(self):
106 """Start the displayhook, initializing resources."""

Callers 1

__call__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected