ipymini 0.1.26__tar.gz → 0.1.28__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.
Files changed (29) hide show
  1. {ipymini-0.1.26 → ipymini-0.1.28}/PKG-INFO +2 -2
  2. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini/__init__.py +3 -1
  3. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini/term/display.py +27 -9
  4. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini/term/ipython_capture.py +1 -2
  5. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini.egg-info/PKG-INFO +2 -2
  6. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini.egg-info/requires.txt +1 -1
  7. {ipymini-0.1.26 → ipymini-0.1.28}/pyproject.toml +1 -1
  8. {ipymini-0.1.26 → ipymini-0.1.28}/LICENSE +0 -0
  9. {ipymini-0.1.26 → ipymini-0.1.28}/README.md +0 -0
  10. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini/__main__.py +0 -0
  11. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini/debug/__init__.py +0 -0
  12. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini/debug/cells.py +0 -0
  13. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini/debug/dap.py +0 -0
  14. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini/kernel.py +0 -0
  15. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini/shell/__init__.py +0 -0
  16. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini/shell/comms.py +0 -0
  17. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini/shell/ops.py +0 -0
  18. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini/shell/shell.py +0 -0
  19. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini/shell/sighelp.py +0 -0
  20. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini/term/__init__.py +0 -0
  21. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini/term/io.py +0 -0
  22. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini/term/streams.py +0 -0
  23. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini.egg-info/SOURCES.txt +0 -0
  24. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini.egg-info/dependency_links.txt +0 -0
  25. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini.egg-info/entry_points.txt +0 -0
  26. {ipymini-0.1.26 → ipymini-0.1.28}/ipymini.egg-info/top_level.txt +0 -0
  27. {ipymini-0.1.26 → ipymini-0.1.28}/setup.cfg +0 -0
  28. {ipymini-0.1.26 → ipymini-0.1.28}/setup.py +0 -0
  29. {ipymini-0.1.26 → ipymini-0.1.28}/share/jupyter/kernels/py/kernel.json +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ipymini
3
- Version: 0.1.26
3
+ Version: 0.1.28
4
4
  Summary: A small, readable Jupyter kernel for Python with strong IPython parity.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
7
7
  License-File: LICENSE
8
8
  Requires-Dist: comm>=0.2.3
9
- Requires-Dist: fastcore>=2.2.34
9
+ Requires-Dist: fastcore>=2.2.37
10
10
  Requires-Dist: ipython>=8.18
11
11
  Requires-Dist: kernmini>=0.1.23
12
12
  Provides-Extra: dev
@@ -1,4 +1,6 @@
1
- __version__ = "0.1.26"
1
+ __version__ = "0.1.28"
2
+
3
+
2
4
 
3
5
 
4
6
 
@@ -1,22 +1,40 @@
1
1
  import contextvars, sys
2
2
 
3
+ from pathlib import PurePath
3
4
  from IPython.core.displayhook import DisplayHook
4
5
  from IPython.core.displaypub import DisplayPublisher
6
+ from IPython.core.formatters import DisplayFormatter
7
+ from IPython.display import DisplayObject, TextDisplayObject
8
+ from fastcore.basics import patch
9
+ from fastcore.xtras import truncstr
5
10
 
6
11
 
7
12
  def full_metadata(obj, metadata):
8
13
  return {**metadata, "full": True} if getattr(obj, "full", False) else metadata
9
14
 
10
15
 
11
- def enable_full_metadata(formatter):
12
- "Preserve `obj.full` in IPython expression and display metadata."
13
- format_obj = formatter.format
14
- if getattr(format_obj, '_full_metadata', False): return
15
- def format_full(obj, include=None, exclude=None):
16
- data, metadata = format_obj(obj, include=include, exclude=exclude)
17
- return data, full_metadata(obj, metadata)
18
- format_full._full_metadata = True
19
- formatter.format = format_full
16
+ _previous_format = DisplayFormatter.format
17
+
18
+ @patch
19
+ def format(self:DisplayFormatter, obj, include=None, exclude=None):
20
+ data,meta = _previous_format(self, obj, include=include, exclude=exclude)
21
+ return data,full_metadata(obj, meta)
22
+
23
+ @patch
24
+ def __repr__(self:DisplayObject):
25
+ s = self.data or self.url or self.filename
26
+ if s is None: return object.__repr__(self)
27
+ return f"{type(self).__name__}({s if isinstance(s, str) else truncstr(str(s), 30)})"
28
+
29
+ # IPython's `DisplayObject.__init__` fetches `data` as a URL when it starts with `http`, and loads it as a file when one of that name exists
30
+ @patch
31
+ def __init__(self:TextDisplayObject, data=None, url=None, filename=None, metadata=None):
32
+ if isinstance(data, PurePath): data = str(data)
33
+ self.url,self.filename,self.data = url,filename,data
34
+ if metadata is not None: self.metadata = metadata
35
+ elif self.metadata is None: self.metadata = {}
36
+ self.reload()
37
+ self._check_data()
20
38
 
21
39
 
22
40
  class MiniDisplayPublisher(DisplayPublisher):
@@ -2,7 +2,7 @@ import contextvars, logging
2
2
  from contextlib import contextmanager
3
3
  from typing import Callable
4
4
 
5
- from .display import MiniDisplayHook, MiniDisplayPublisher, enable_full_metadata
5
+ from .display import MiniDisplayHook, MiniDisplayPublisher
6
6
  from .io import thread_local_io
7
7
  from .streams import MiniStream, coalesce_streams
8
8
 
@@ -12,7 +12,6 @@ log = logging.getLogger("ipymini.term")
12
12
  class IPythonCapture:
13
13
  def __init__(self, shell, request_input: Callable[[str, bool], str]):
14
14
  self.shell = shell
15
- enable_full_metadata(shell.display_formatter)
16
15
  self.request_input = request_input
17
16
  self.display_sender = None
18
17
  self.display_live = contextvars.ContextVar("ipymini.display_live", default=False)
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ipymini
3
- Version: 0.1.26
3
+ Version: 0.1.28
4
4
  Summary: A small, readable Jupyter kernel for Python with strong IPython parity.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
7
7
  License-File: LICENSE
8
8
  Requires-Dist: comm>=0.2.3
9
- Requires-Dist: fastcore>=2.2.34
9
+ Requires-Dist: fastcore>=2.2.37
10
10
  Requires-Dist: ipython>=8.18
11
11
  Requires-Dist: kernmini>=0.1.23
12
12
  Provides-Extra: dev
@@ -1,5 +1,5 @@
1
1
  comm>=0.2.3
2
- fastcore>=2.2.34
2
+ fastcore>=2.2.37
3
3
  ipython>=8.18
4
4
  kernmini>=0.1.23
5
5
 
@@ -10,7 +10,7 @@ readme = "README.md"
10
10
  requires-python = ">=3.11"
11
11
  dependencies = [
12
12
  "comm>=0.2.3",
13
- "fastcore>=2.2.34",
13
+ "fastcore>=2.2.37",
14
14
  "ipython>=8.18",
15
15
  "kernmini>=0.1.23",
16
16
  ]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes