Skip to content

Commit

Permalink
Merge branch 'main' into eqctier3-687ee928-cb36-491a-8a59-7fb2071caed5
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Nov 12, 2024
2 parents bc8d002 + de6abe2 commit 4450ac4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand Down Expand Up @@ -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]
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -458,7 +458,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.11.10"
}
},
"nbformat": 4,
Expand Down
8 changes: 7 additions & 1 deletion scripts/validate-headings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
"## ℹ️ 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)

title_count = 0
admonition_count = 0
headings_count = dict.fromkeys(HEADINGS, 0)
for cell in notebook.cells:
if cell["cell_type"] != "markdown":
Expand All @@ -27,7 +30,9 @@ def validate_headers(path: Path) -> None:

if line.startswith("# "):
title_count += 1
continue
elif line == f"```{{admonition}} {ADMONITION_TITLE}":
admonition_count += 1

if not path.name.startswith("template"):
assert title_count, f"{path=!s}: The first line is not a title."

Expand All @@ -39,6 +44,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=}"

Expand Down

0 comments on commit 4450ac4

Please sign in to comment.