From e4ecdcb8cd60f6c68652aa16b59ab0831c075063 Mon Sep 17 00:00:00 2001 From: Jakub Recman Date: Fri, 17 Apr 2026 15:06:46 +0200 Subject: [PATCH 1/2] Normalize notebook paths --- .github/workflows/notebook-qa.yml | 5 ++--- process-notebooks/checkers/qa_config.py | 11 +++++++++-- process-notebooks/checkers/write_gha_config.py | 5 ++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/notebook-qa.yml b/.github/workflows/notebook-qa.yml index 3df1fcc..43382e0 100644 --- a/.github/workflows/notebook-qa.yml +++ b/.github/workflows/notebook-qa.yml @@ -78,10 +78,9 @@ jobs: NBS=$(printf '%s\n' $INPUT_NOTEBOOKS) elif [ -n "$BASE_SHA" ]; then NBS=$(git diff --name-only --diff-filter=ACMR "$BASE_SHA" HEAD -- '*.ipynb' \ - | grep -v '\.ipynb_checkpoints/' \ - | sed 's|^|./|' || true) + | grep -v '\.ipynb_checkpoints/' || true) else - NBS=$(find . -name '*.ipynb' -not -path '*/.ipynb_checkpoints/*') + NBS=$(find . -name '*.ipynb' -not -path '*/.ipynb_checkpoints/*' -printf '%P\n') fi if [ -z "$NBS" ]; then echo "files=" >> "$GITHUB_OUTPUT" diff --git a/process-notebooks/checkers/qa_config.py b/process-notebooks/checkers/qa_config.py index b33a6cc..65e2753 100644 --- a/process-notebooks/checkers/qa_config.py +++ b/process-notebooks/checkers/qa_config.py @@ -42,6 +42,11 @@ PYNBLINT_DEFAULT_EXCLUDE = ["missing-h1-MD-heading", "imports-beyond-first-cell"] +def _normalize_path(path: str) -> str: + """Remove leading ./ from a path for consistent fnmatch matching.""" + return path.removeprefix("./") + + def load_config(config_path: str = ".github/notebook-qa.yml") -> dict[str, Any]: """ Load QA configuration from YAML file. @@ -95,7 +100,8 @@ def is_notebook_skipped(config: dict[str, Any], notebook: str) -> bool: True if notebook should be skipped, False otherwise """ skip_patterns = config.get("skip_notebooks", []) - return any(fnmatch(notebook, pattern) for pattern in skip_patterns) + notebook = _normalize_path(notebook) + return any(fnmatch(notebook, _normalize_path(pattern)) for pattern in skip_patterns) def is_check_skipped_for_notebook(config: dict[str, Any], check_id: str, notebook: str) -> bool: @@ -111,8 +117,9 @@ def is_check_skipped_for_notebook(config: dict[str, Any], check_id: str, noteboo True if check should be skipped for this notebook, False otherwise """ per_notebook = config.get("notebooks", {}) + notebook = _normalize_path(notebook) for pattern, settings in per_notebook.items(): - if fnmatch(notebook, pattern): + if fnmatch(notebook, _normalize_path(pattern)): skip_checks = settings.get("skip", []) if check_id in skip_checks: return True diff --git a/process-notebooks/checkers/write_gha_config.py b/process-notebooks/checkers/write_gha_config.py index 9184535..cd26052 100644 --- a/process-notebooks/checkers/write_gha_config.py +++ b/process-notebooks/checkers/write_gha_config.py @@ -30,9 +30,8 @@ def parse_notebook_list(raw: str) -> list[str]: """Parse notebook list from newline-separated (or space-separated) string.""" - if "\n" in raw: - return [nb.strip() for nb in raw.splitlines() if nb.strip()] - return raw.split() + nbs = [nb.strip() for nb in raw.splitlines() if nb.strip()] if "\n" in raw else raw.split() + return [nb.removeprefix("./") for nb in nbs] def write_multiline_output(fh, key: str, lines: list[str]) -> None: From 975e4ffd9c43d7316772f0cb4e370dc7e6239de9 Mon Sep 17 00:00:00 2001 From: Jakub Recman Date: Fri, 17 Apr 2026 15:10:14 +0200 Subject: [PATCH 2/2] Update README notebook path examples --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7e667b3..e3b23c0 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ disabled_checks: # Notebooks to skip entirely (all checks), supports glob patterns skip_notebooks: - - "./draft.ipynb" # To skip notebooks at the top level include "./" to ensure that the path is resolved + - "draft.ipynb" - "notebooks/draft.ipynb" - "notebooks/experimental/**"