mdformat-py-edu-fr 0.1.6__py3-none-any.whl → 0.1.8__py3-none-any.whl

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,10 +1,10 @@
1
1
  import sys
2
2
  from pathlib import Path
3
- from typing import List, Optional
3
+ from typing import List
4
4
 
5
5
  import mdformat
6
6
 
7
- from .format_with_jupytext import format_str
7
+ from .format_with_jupytext import format_md_with_jupytext
8
8
 
9
9
  try:
10
10
  from importlib.metadata import version
@@ -106,7 +106,7 @@ def format_file(filepath: Path, check: bool = False, verbose: bool = False) -> b
106
106
  _filename=str(filepath),
107
107
  )
108
108
 
109
- formatted_str = format_str(formatted_str)
109
+ formatted_str = format_md_with_jupytext(formatted_str, filepath)
110
110
 
111
111
  formatted = formatted_str == original_str
112
112
 
@@ -13,7 +13,7 @@ path_config_file = Path(__file__).absolute().parent / "jupytext.toml"
13
13
  config = jupytext.config.load_jupytext_configuration_file(str(path_config_file))
14
14
 
15
15
 
16
- def format_str(text: str) -> str:
16
+ def format_md_with_jupytext(text: str, path_input_file: Path | None = None) -> str:
17
17
  """Format the code of a notebook code using jupytext"""
18
18
 
19
19
  notebook = jupytext.reads(text, fmt="md:myst")
@@ -36,12 +36,17 @@ def format_str(text: str) -> str:
36
36
  learning[a][b] = [s.strip() for s in learning[a][b].split(",")]
37
37
 
38
38
  for cell in notebook.cells:
39
- if language == "python" and cell["cell_type"] == "code":
39
+ if (
40
+ language == "python"
41
+ and cell["cell_type"] == "code"
42
+ and cell["metadata"].get("format", True)
43
+ ):
40
44
  try:
41
45
  cell.source = format_code_with_ruff(cell["source"].strip())
42
46
  except RuffFormattingError as exc:
43
47
  print(
44
- f"Ruff formatting failed for cell source:\n{cell.source}\n",
48
+ f"Ruff formatting failed for file\n{path_input_file or '???'}\n"
49
+ f"cell source:\n{cell.source}\n",
45
50
  exc,
46
51
  file=sys.stderr,
47
52
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mdformat-py-edu-fr
3
- Version: 0.1.6
3
+ Version: 0.1.8
4
4
  Summary: Tiny wrapper around mdformat for the py-edu-fr project
5
5
  Author-Email: Pierre Augier <pierre.augier@univ-grenoble-alpes.fr>
6
6
  License-Expression: BSD-3-Clause
@@ -3,13 +3,13 @@ mdformat_myst_pef/__init__.py,sha256=aYAObHCbEiPg3WwadhJ_TB7SCk8bGlTTmNMO2tj1Q40
3
3
  mdformat_myst_pef/_directives.py,sha256=gr9XXHeE1OpEPrUKZdy2S9iI4aQVgX4kO2UyhJlmSEk,4793
4
4
  mdformat_myst_pef/plugin.py,sha256=fFqNG4UV_2aNSDYnJxbgV541K3qf7jQ53VMBSB1ktCU,7733
5
5
  mdformat_myst_pef/py.typed,sha256=8PjyZ1aVoQpRVvt71muvuq5qE-jTFZkK-GLHkhdebmc,26
6
- mdformat_py_edu_fr-0.1.6.dist-info/METADATA,sha256=AAaWpFdS1JDvW1cjbNRpMu8b9HX4cWdWOhdH9h37qUA,1506
7
- mdformat_py_edu_fr-0.1.6.dist-info/WHEEL,sha256=RSz6kXtM6TF3IJK4O7lm4V0QzFJUHF9t5pxUi4i5D34,104
8
- mdformat_py_edu_fr-0.1.6.dist-info/entry_points.txt,sha256=dNsCwKXSNYQUbo19idpAR7WOLX6XiklUmMmb_Tfj7gs,149
9
- mdformat_py_edu_fr-0.1.6.dist-info/licenses/LICENSE.txt,sha256=86p_CLJNsO7121AMS-JOKevnqSH4FKqOAbRPaf2Bu0U,1524
10
- mdformat_py_edu_fr/__init__.py,sha256=a87wI51gBRuFn1_IauF42noia0IE4t0kmOiJRIWVVl4,3312
6
+ mdformat_py_edu_fr-0.1.8.dist-info/METADATA,sha256=a_9_q6sZwrT1mjDB7EqcJqoiimus_0GFKxBC_OKK5AA,1506
7
+ mdformat_py_edu_fr-0.1.8.dist-info/WHEEL,sha256=XavltlFgTGbuUtnh6QqpzgnrcFlEfDRGf5pyLtB4b10,104
8
+ mdformat_py_edu_fr-0.1.8.dist-info/entry_points.txt,sha256=dNsCwKXSNYQUbo19idpAR7WOLX6XiklUmMmb_Tfj7gs,149
9
+ mdformat_py_edu_fr-0.1.8.dist-info/licenses/LICENSE.txt,sha256=86p_CLJNsO7121AMS-JOKevnqSH4FKqOAbRPaf2Bu0U,1524
10
+ mdformat_py_edu_fr/__init__.py,sha256=l1_JIUAgbXQcn6voAW8CxSgmMWxGF8hfdnD09Q73pTo,3338
11
11
  mdformat_py_edu_fr/__main__.py,sha256=SI9uVJaNxyo8MVoAzb2pJWdXszT-zdWl6afekldFn2c,2509
12
- mdformat_py_edu_fr/format_with_jupytext.py,sha256=-YoeTGofr3iL51CLXSD4phyMD5OWwsiu8EuBJ1roE50,2334
12
+ mdformat_py_edu_fr/format_with_jupytext.py,sha256=blASTXzHaBpcCMrW5-CcXsHYqMUdPFZn14uDJ90olR4,2531
13
13
  mdformat_py_edu_fr/jupytext.toml,sha256=ZQwweaKSvIGXWw-lEwJfnzTPSbEqiGQjNmPBxsQVxmQ,872
14
14
  mdformat_py_edu_fr/util_ruff.py,sha256=FDatJwUPcB3YElJmLfNfXh3ERzJyTIkikGigXGVb8Fw,647
15
- mdformat_py_edu_fr-0.1.6.dist-info/RECORD,,
15
+ mdformat_py_edu_fr-0.1.8.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: pdm-backend (2.4.6.dev3+g3976183)
2
+ Generator: pdm-backend (2.4.6.dev7+gedb43f1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any