8000 Ignored `.md` files should not be read with `jupytext` · Issue #239 · danielfrg/mkdocs-jupyter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Ignored .md files should not be read with jupytext #239
Open
@jorenham

Description

@jorenham

As I also explained in mwouts/jupytext#1306 (comment), the Plugin.should_include at

def should_include(self, file):
ext = os.path.splitext(str(file.abs_src_path))[-1]
if ext not in self._supported_extensions:
return False
if ext == ".md":
# only include markdown files with jupytext frontmatter
# that explicitly specifies a python kernel
try:
data = jupytext.read(file.abs_src_path)
if not (
(meta := data.get("metadata", {}))
and (kernelspec := meta.get("kernelspec"))
and kernelspec["language"] == "python"
):
return False
except Exception:
return False
srcpath = pathlib.PurePath(file.abs_src_path)
include = None
ignore = None
for pattern in self.config["ignore"]:
if srcpath.match(pattern):
ignore = True
for pattern in self.config["include"]:
if srcpath.match(pattern):
include = True
return include and not ignore
will attempt to read any .md with jupytext.read, even if .md files are configured to not be included, or to be ignored.

In https://github.com/jorenham/lmo/, this results in many confusing warning messages to be logged to stderr, specifically, the following is printed 12x when I run uv mkdocs build:

INFO    -  MissingIDFieldWarning: Cell is missing an id field, this will become a hard error in future nbformat versions. You may want to use `normalize()` on your notebooks before validations (available since nbformat 5.1.4). Previous versions of nbformat are fixing this issue transparently, and will stop doing so in the future.
             File "/home/joren/Workspace/lmo/.venv/lib/python3.12/site-packages/nbformat/validator.py", line 351, in _normalize
               warnings.warn(
             File "/home/joren/Workspace/lmo/.venv/lib/python3.12/site-packages/nbformat/__init__.py", line 96, in
               validate(nb)

As you can see from mwouts/jupytext#1306, it took me many hours to figure this out, so I think I at least deserve a cookie now. And it would be even better if this could be fixed :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0