From 722e53439d8c914ca59245bf8b87b2a4aa147150 Mon Sep 17 00:00:00 2001 From: Mattia Almansi Date: Tue, 29 Oct 2024 14:42:16 +0100 Subject: [PATCH 1/4] make admonition mandatory (#252) --- scripts/validate-headings.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/validate-headings.py b/scripts/validate-headings.py index b7782e19..9169c50f 100644 --- a/scripts/validate-headings.py +++ b/scripts/validate-headings.py @@ -17,6 +17,7 @@ def validate_headers(path: Path) -> None: notebook = nbformat.read(path, nbformat.NO_CONVERT) title_count = 0 + admonition_count = 0 headings_count = dict.fromkeys(HEADINGS, 0) for cell in notebook.cells: if cell["cell_type"] != "markdown": @@ -27,7 +28,9 @@ def validate_headers(path: Path) -> None: if line.startswith("# "): title_count += 1 - continue + elif line.startswith("```{admonition}"): + admonition_count += 1 + if not path.name.startswith("template"): assert title_count, f"{path=!s}: The first line is not a title." @@ -39,6 +42,7 @@ def validate_headers(path: Path) -> None: assert not line.startswith("## "), f"{path=!s}: Invalid H2 {line=}" assert title_count == 1, f"{path=!s}: Invalid {title_count=}" + assert admonition_count == 1, f"{path=!s}: Invalid {admonition_count=}" for heading, header_count in headings_count.items(): assert header_count == 1, f"{path=!s}: Invalid {header_count=} of {heading=}" From 481d97f7f1b36ee29dd4815940a4bfe934aa0da9 Mon Sep 17 00:00:00 2001 From: Mattia Almansi Date: Wed, 30 Oct 2024 15:36:45 +0100 Subject: [PATCH 2/4] improve admonition checker (#254) * improve admonition checker * cleanup --- .../satellite_satellite-ozone-v1_climate-monitoring_q01.ipynb | 4 ++-- scripts/validate-headings.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Satellite_ECVs/Atmospheric_Composition/satellite_satellite-ozone-v1_climate-monitoring_q01.ipynb b/Satellite_ECVs/Atmospheric_Composition/satellite_satellite-ozone-v1_climate-monitoring_q01.ipynb index 9838e960..fed1bf48 100644 --- a/Satellite_ECVs/Atmospheric_Composition/satellite_satellite-ozone-v1_climate-monitoring_q01.ipynb +++ b/Satellite_ECVs/Atmospheric_Composition/satellite_satellite-ozone-v1_climate-monitoring_q01.ipynb @@ -50,7 +50,7 @@ "source": [ "## 📢 Quality assessment statements\n", "\n", - "```{admonition} These are the key outcomes of this quality assessment\n", + "```{admonition} These are the key outcomes of this assessment\n", ":class: note\n", "* The MERGED-UV v2000 provides a long-term, consistent record of total column ozone concentration and is therefore valuable for providing insight into the evolution of the ozone layer, although data prior to 2004 should be carefully evaluated.\n", "* The MERGED-UV v2000 does not include measurements during the polar night at latitudes higher than 57.5° in both hemispheres and therefore cannot be used to describe the ozone climatology and trends over these regions.\n", @@ -458,7 +458,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.9" + "version": "3.11.10" } }, "nbformat": 4, diff --git a/scripts/validate-headings.py b/scripts/validate-headings.py index 9169c50f..07400b07 100644 --- a/scripts/validate-headings.py +++ b/scripts/validate-headings.py @@ -28,7 +28,9 @@ def validate_headers(path: Path) -> None: if line.startswith("# "): title_count += 1 - elif line.startswith("```{admonition}"): + elif ( + line == "```{admonition} These are the key outcomes of this assessment" + ): admonition_count += 1 if not path.name.startswith("template"): From 28c56488994c7ecb86a77aabf3a282958e49bad6 Mon Sep 17 00:00:00 2001 From: Mattia Almansi Date: Wed, 30 Oct 2024 15:47:17 +0100 Subject: [PATCH 3/4] improve pre-commit script (#255) --- scripts/validate-headings.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/validate-headings.py b/scripts/validate-headings.py index 07400b07..491e27e6 100644 --- a/scripts/validate-headings.py +++ b/scripts/validate-headings.py @@ -12,6 +12,8 @@ "## ℹ️ If you want to know more", ) +ADMONITION_TITLE = "These are the key outcomes of this assessment" + def validate_headers(path: Path) -> None: notebook = nbformat.read(path, nbformat.NO_CONVERT) @@ -28,9 +30,7 @@ def validate_headers(path: Path) -> None: if line.startswith("# "): title_count += 1 - elif ( - line == "```{admonition} These are the key outcomes of this assessment" - ): + elif line == f"```{{admonition}} {ADMONITION_TITLE}": admonition_count += 1 if not path.name.startswith("template"): From de6abe2dab2747797c4ea2900f2dde8d36b359c5 Mon Sep 17 00:00:00 2001 From: Mattia Almansi Date: Mon, 11 Nov 2024 09:17:04 +0100 Subject: [PATCH 4/4] pre-commit autoupdate (#262) --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd666ec0..dd5f95c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: - id: check-toml - id: check-merge-conflict - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.9 + rev: v0.7.3 hooks: - id: ruff args: [--fix, --show-fixes] @@ -21,7 +21,7 @@ repos: - id: pretty-format-toml args: [--autofix] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.2 + rev: v1.13.0 hooks: - id: mypy args: [--strict, --ignore-missing-imports] @@ -50,13 +50,13 @@ repos: types: [jupyter] additional_dependencies: [nbformat] - repo: https://github.com/executablebooks/mdformat - rev: 0.7.17 + rev: 0.7.18 hooks: - id: mdformat additional_dependencies: - mdformat-gfm - repo: https://github.com/kynan/nbstripout - rev: 0.7.1 + rev: 0.8.0 hooks: - id: nbstripout args: [--drop-empty-cells, --keep-count, --keep-output, --extra-keys, metadata.kernelspec]