Skip to content

Commit

Permalink
DEP: bump minimal supported IPython version to 7.32, declare ipykerne…
Browse files Browse the repository at this point in the history
…l as optional dep, cleanup
  • Loading branch information
neutrinoceros committed Apr 29, 2024
1 parent 0c06ac3 commit 3ef8d9b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 43 deletions.
1 change: 1 addition & 0 deletions astropy/utils/compat/optional_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"fsspec",
"h5py",
"html5lib",
"ipykernel",
"IPython",
"jplephem",
"lxml",
Expand Down
55 changes: 14 additions & 41 deletions astropy/utils/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
_CAN_RESIZE_TERMINAL = False

from astropy import conf
from astropy.utils.compat.optional_deps import HAS_IPYKERNEL, HAS_IPYTHON

from .decorators import classproperty, deprecated
from .misc import isiterable
Expand All @@ -49,42 +50,33 @@ class _IPython:

@classproperty
def get_ipython(cls):
try:
if HAS_IPYTHON:

Check warning on line 53 in astropy/utils/console.py

View check run for this annotation

Codecov / codecov/patch

astropy/utils/console.py#L53

Added line #L53 was not covered by tests
from IPython import get_ipython
except ImportError:
pass
return get_ipython

return get_ipython
raise ModuleNotFoundError("IPython is not installed")

Check warning on line 57 in astropy/utils/console.py

View check run for this annotation

Codecov / codecov/patch

astropy/utils/console.py#L56-L57

Added lines #L56 - L57 were not covered by tests

@classproperty
def OutStream(cls):
if not hasattr(cls, "_OutStream"):
cls._OutStream = None
try:
cls.get_ipython()
except NameError:
return None

try:
if HAS_IPYKERNEL:

Check warning on line 62 in astropy/utils/console.py

View check run for this annotation

Codecov / codecov/patch

astropy/utils/console.py#L62

Added line #L62 was not covered by tests
from ipykernel.iostream import OutStream
except ImportError:
try:
from IPython.zmq.iostream import OutStream
except ImportError:
return None

cls._OutStream = OutStream
cls._OutStream = OutStream

Check warning on line 65 in astropy/utils/console.py

View check run for this annotation

Codecov / codecov/patch

astropy/utils/console.py#L65

Added line #L65 was not covered by tests
else:
cls._OutStream = None

Check warning on line 67 in astropy/utils/console.py

View check run for this annotation

Codecov / codecov/patch

astropy/utils/console.py#L67

Added line #L67 was not covered by tests

return cls._OutStream

@classproperty
def ipyio(cls):
if not hasattr(cls, "_ipyio"):
try:
if HAS_IPYTHON:

Check warning on line 74 in astropy/utils/console.py

View check run for this annotation

Codecov / codecov/patch

astropy/utils/console.py#L74

Added line #L74 was not covered by tests
from IPython.utils import io
except ImportError:
cls._ipyio = None
else:

cls._ipyio = io
else:
cls._ipyio = None

Check warning on line 79 in astropy/utils/console.py

View check run for this annotation

Codecov / codecov/patch

astropy/utils/console.py#L79

Added line #L79 was not covered by tests
return cls._ipyio


Expand All @@ -108,26 +100,7 @@ def isatty(file):
if _IPython.OutStream is None or (not isinstance(file, _IPython.OutStream)):
return False

# File is an IPython OutStream. Check whether:
# - File name is 'stdout'; or
# - File wraps a Console
if getattr(file, "name", None) == "stdout":
return True

if hasattr(file, "stream"):
# FIXME: pyreadline has no had new release since 2015, drop it when
# IPython minversion is 5.x.
# On Windows, in IPython 2 the standard I/O streams will wrap
# pyreadline.Console objects if pyreadline is available; this should
# be considered a TTY.
try:
from pyreadline.console import Console as PyreadlineConsole
except ImportError:
return False

return isinstance(file.stream, PyreadlineConsole)

return False
return getattr(file, "name", None) == "stdout"

Check warning on line 103 in astropy/utils/console.py

View check run for this annotation

Codecov / codecov/patch

astropy/utils/console.py#L103

Added line #L103 was not covered by tests


@deprecated("6.1", alternative="shutil.get_terminal_size")
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ test = [
test_all = [
"astropy[test]", # installs the [test] dependencies
"objgraph",
"ipython>=4.2",
"ipykernel",
"ipython>=7.32",
"coverage[toml]",
"skyfield>=1.20",
"sgp4>=2.3",
Expand Down Expand Up @@ -88,7 +89,8 @@ all = [
"mpmath",
"asdf-astropy>=0.3",
"bottleneck",
"ipython>=4.2",
"ipykernel",
"ipython>=7.32",
"pytest>=7.0",
"fsspec[http]>=2023.4.0",
"s3fs>=2023.4.0",
Expand Down

0 comments on commit 3ef8d9b

Please sign in to comment.