ipython-icat 0.4.0__tar.gz → 0.4.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ipython-icat
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Summary: IPython magic command for displaying images in kitty terminal
5
5
  Author-email: Tony Kabilan Okeke <tonykabilanokeke@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/Kabilan108/ipython-icat
@@ -3,18 +3,18 @@ from io import BytesIO
3
3
  from os import getenv
4
4
  from pathlib import Path
5
5
  from subprocess import run
6
+ from typing import Optional
6
7
 
7
8
  import matplotlib
9
+ from IPython.core.getipython import get_ipython
8
10
  from IPython.core.magic import Magics, line_magic, magics_class
9
11
  from IPython.core.magic_arguments import argument, magic_arguments, parse_argstring
10
- from IPython.core.getipython import get_ipython
11
12
  from matplotlib import interactive, is_interactive
12
13
  from matplotlib._pylab_helpers import Gcf
13
14
  from matplotlib.backend_bases import FigureManagerBase, _Backend
14
15
  from matplotlib.backends.backend_agg import FigureCanvasAgg
15
16
  from PIL import Image
16
17
 
17
-
18
18
  if hasattr(sys, "ps1") or sys.flags.interactive:
19
19
  interactive(True)
20
20
 
@@ -90,12 +90,16 @@ class ICatMagics(Magics):
90
90
 
91
91
  obj = _resolve_target(self.shell, target)
92
92
  if obj is None:
93
- print(f"Error: could not resolve '{target}' as an image expression or file path.")
93
+ print(
94
+ f"Error: could not resolve '{target}' as an image expression or file path."
95
+ )
94
96
  return
95
97
 
96
98
  img = _coerce_to_image(obj)
97
99
  if img is None:
98
- print(f"Error: '{target}' did not evaluate to a PIL Image or readable image path.")
100
+ print(
101
+ f"Error: '{target}' did not evaluate to a PIL Image or readable image path."
102
+ )
99
103
  return
100
104
 
101
105
  # resize the image if width or height is specified
@@ -108,7 +112,7 @@ class ICatMagics(Magics):
108
112
  _icat(output=False, input=buf.getbuffer())
109
113
 
110
114
 
111
- def icat(img: Image.Image, width: int = None, height: int = None):
115
+ def icat(img: Image.Image, width: Optional[int] = None, height: Optional[int] = None):
112
116
  img_ = img.copy()
113
117
  with BytesIO() as buf:
114
118
  if width or height:
@@ -183,7 +187,9 @@ def _print_status(shell) -> None:
183
187
  current = matplotlib.get_backend()
184
188
  except Exception:
185
189
  pass
186
- print(f"icat: enabled={enabled}, matplotlib_backend={current!r}, prev_backend={prev!r}")
190
+ print(
191
+ f"icat: enabled={enabled}, matplotlib_backend={current!r}, prev_backend={prev!r}"
192
+ )
187
193
 
188
194
 
189
195
  def _resolve_target(shell, target: str):
@@ -204,7 +210,7 @@ def _resolve_target(shell, target: str):
204
210
 
205
211
  def _coerce_to_image(obj):
206
212
  if isinstance(obj, Image.Image):
207
- return obj
213
+ return obj.copy()
208
214
 
209
215
  if isinstance(obj, (str, Path)):
210
216
  path = Path(obj).expanduser()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ipython-icat
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Summary: IPython magic command for displaying images in kitty terminal
5
5
  Author-email: Tony Kabilan Okeke <tonykabilanokeke@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/Kabilan108/ipython-icat
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ipython-icat"
3
- version = "0.4.0"
3
+ version = "0.4.1"
4
4
  description = "IPython magic command for displaying images in kitty terminal"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.8"
File without changes
File without changes
File without changes