Skip to content

Commit 4f3d078

Browse files
committed
CLN: Remove io/formats/terminal.py
Remaining is_terminal function is used in core/config_init.py, and as this function is not meant to be public, we can move it there. This will help with dependency organization of pandas' modules. Follow-up to pandas-devgh-25886.
1 parent 7721f70 commit 4f3d078

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

pandas/core/config_init.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
is_bool, is_callable, is_instance_factory, is_int, is_one_of_factory,
1515
is_text)
1616

17-
from pandas.io.formats.terminal import is_terminal
18-
1917
# compute
2018

2119
use_bottleneck_doc = """
@@ -287,6 +285,23 @@ def table_schema_cb(key):
287285
_enable_data_resource_formatter(cf.get_option(key))
288286

289287

288+
def is_terminal():
289+
"""
290+
Detect if Python is running in a terminal.
291+
292+
Returns True if Python is running in a terminal or False if not.
293+
"""
294+
try:
295+
ip = get_ipython()
296+
except NameError: # assume standard Python interpreter in a terminal
297+
return True
298+
else:
299+
if hasattr(ip, 'kernel'): # IPython as a Jupyter kernel
300+
return False
301+
else: # IPython in a terminal
302+
return True
303+
304+
290305
with cf.config_prefix('display'):
291306
cf.register_option('precision', 6, pc_precision_doc, validator=is_int)
292307
cf.register_option('float_format', None, float_format_doc,

pandas/io/formats/terminal.py

-22
This file was deleted.

0 commit comments

Comments
 (0)