pdit 0.3.2__tar.gz → 0.5.0__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 (27) hide show
  1. {pdit-0.3.2/pdit.egg-info → pdit-0.5.0}/PKG-INFO +1 -1
  2. {pdit-0.3.2 → pdit-0.5.0}/pdit/ipython_executor.py +6 -1
  3. {pdit-0.3.2 → pdit-0.5.0/pdit.egg-info}/PKG-INFO +1 -1
  4. {pdit-0.3.2 → pdit-0.5.0}/pyproject.toml +1 -1
  5. {pdit-0.3.2 → pdit-0.5.0}/tests/test_ipython_executor.py +29 -0
  6. {pdit-0.3.2 → pdit-0.5.0}/LICENSE +0 -0
  7. {pdit-0.3.2 → pdit-0.5.0}/MANIFEST.in +0 -0
  8. {pdit-0.3.2 → pdit-0.5.0}/README.md +0 -0
  9. {pdit-0.3.2 → pdit-0.5.0}/pdit/__init__.py +0 -0
  10. {pdit-0.3.2 → pdit-0.5.0}/pdit/_demo.py +0 -0
  11. {pdit-0.3.2 → pdit-0.5.0}/pdit/_static/assets/index-1w8kifoA.js +0 -0
  12. {pdit-0.3.2 → pdit-0.5.0}/pdit/_static/assets/index-rS96z8hq.css +0 -0
  13. {pdit-0.3.2 → pdit-0.5.0}/pdit/_static/export.html +0 -0
  14. {pdit-0.3.2 → pdit-0.5.0}/pdit/_static/index.html +0 -0
  15. {pdit-0.3.2 → pdit-0.5.0}/pdit/cli.py +0 -0
  16. {pdit-0.3.2 → pdit-0.5.0}/pdit/exporter.py +0 -0
  17. {pdit-0.3.2 → pdit-0.5.0}/pdit/file_watcher.py +0 -0
  18. {pdit-0.3.2 → pdit-0.5.0}/pdit/server.py +0 -0
  19. {pdit-0.3.2 → pdit-0.5.0}/pdit.egg-info/SOURCES.txt +0 -0
  20. {pdit-0.3.2 → pdit-0.5.0}/pdit.egg-info/dependency_links.txt +0 -0
  21. {pdit-0.3.2 → pdit-0.5.0}/pdit.egg-info/entry_points.txt +0 -0
  22. {pdit-0.3.2 → pdit-0.5.0}/pdit.egg-info/requires.txt +0 -0
  23. {pdit-0.3.2 → pdit-0.5.0}/pdit.egg-info/top_level.txt +0 -0
  24. {pdit-0.3.2 → pdit-0.5.0}/setup.cfg +0 -0
  25. {pdit-0.3.2 → pdit-0.5.0}/tests/test_file_watcher.py +0 -0
  26. {pdit-0.3.2 → pdit-0.5.0}/tests/test_local_import.py +0 -0
  27. {pdit-0.3.2 → pdit-0.5.0}/tests/test_server.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pdit
3
- Version: 0.3.2
3
+ Version: 0.5.0
4
4
  Summary: Interactive Python code editor with inline execution results
5
5
  Author: Harry Vangberg
6
6
  License: MIT
@@ -167,6 +167,9 @@ del _register_pdit_runtime_hooks
167
167
 
168
168
  for node in tree.body:
169
169
  line_start = node.lineno
170
+ if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
171
+ if node.decorator_list:
172
+ line_start = min(dec.lineno for dec in node.decorator_list)
170
173
  line_end = node.end_lineno or node.lineno
171
174
 
172
175
  # Extract source
@@ -194,7 +197,7 @@ del _register_pdit_runtime_hooks
194
197
  """Process MIME bundle data into output dicts.
195
198
 
196
199
  Passes through MIME types directly instead of translating to custom types.
197
- Uses priority order: image > html > json > plain text.
200
+ Uses priority order: image > html > markdown > json > plain text.
198
201
  """
199
202
  output: list[dict] = []
200
203
 
@@ -207,6 +210,8 @@ del _register_pdit_runtime_hooks
207
210
  output.append({"type": mime_type, "content": data[mime_type]})
208
211
  elif 'text/html' in data:
209
212
  output.append({"type": "text/html", "content": data['text/html']})
213
+ elif 'text/markdown' in data:
214
+ output.append({"type": "text/markdown", "content": data['text/markdown']})
210
215
  elif 'application/json' in data:
211
216
  json_data = data['application/json']
212
217
  output.append({"type": "application/json", "content": json.dumps(json_data)})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pdit
3
- Version: 0.3.2
3
+ Version: 0.5.0
4
4
  Summary: Interactive Python code editor with inline execution results
5
5
  Author: Harry Vangberg
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pdit"
7
- version = "0.3.2"
7
+ version = "0.5.0"
8
8
  description = "Interactive Python code editor with inline execution results"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9,<3.14"
@@ -361,6 +361,15 @@ class TestMimeTypeProcessing:
361
361
  result = results[1]
362
362
  assert result["output"][0]["type"] == "text/plain"
363
363
 
364
+ async def test_ipython_display_markdown(self, executor):
365
+ """Test IPython.display.Markdown renders as text/markdown."""
366
+ script = 'from IPython.display import Markdown\nMarkdown("# Hej")'
367
+ results = await collect_results(executor.execute_script(script))
368
+
369
+ result = results[-1]
370
+ assert result["output"][0]["type"] == "text/markdown"
371
+ assert "# Hej" in result["output"][0]["content"]
372
+
364
373
  async def test_none_result(self, executor):
365
374
  """Test that None results produce no output."""
366
375
  script = "None"
@@ -448,6 +457,26 @@ result"""
448
457
  assert results[2]["isInvisible"] is True # assignment
449
458
  assert "7" in results[3]["output"][0]["content"]
450
459
 
460
+ async def test_function_decorator_applied(self, executor):
461
+ """Test that function decorators are applied."""
462
+ script = """from functools import wraps
463
+
464
+ def add_one(fn):
465
+ @wraps(fn)
466
+ def wrapper(*args, **kwargs):
467
+ return fn(*args, **kwargs) + 1
468
+ return wrapper
469
+
470
+ @add_one
471
+ def add(a, b):
472
+ return a + b
473
+
474
+ add(2, 3)"""
475
+ results = await collect_results(executor.execute_script(script))
476
+
477
+ final_result = results[-1]
478
+ assert "6" in final_result["output"][0]["content"]
479
+
451
480
  async def test_list_comprehension(self, executor):
452
481
  """Test list comprehension execution."""
453
482
  script = "[x**2 for x in range(5)]"
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
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