Skip to content

Commit

Permalink
Merge branch 'main' into eqctier3-8d67bc13-71c2-4aa1-b1bb-e7805302e724
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Nov 18, 2024
2 parents b81ebbf + de6abe2 commit c743075
Show file tree
Hide file tree
Showing 4 changed files with 17 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
1 change: 1 addition & 0 deletions scripts/fix-markdown-strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"## 🌍 Use Case:": "## 🌍 Use case:",
"## Quality assessment question": "## ❓ Quality assessment question",
"## Quality Assessment Question": "## ❓ Quality assessment question",
"## Quality Assessment question": "## ❓ Quality assessment question",
"## ❓ Quality Assessment Question": "## ❓ Quality assessment question",
"## Quality assessment statement": "## 📢 Quality assessment statement",
"## Quality Assessment Statement": "## 📢 Quality assessment statement",
Expand Down
11 changes: 10 additions & 1 deletion scripts/validate-headings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,29 @@
"## ℹ️ 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":
continue

for line in cell.get("source", "").splitlines():
line = line.strip()

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."

for heading in headings_count:
if line.startswith(heading):
Expand All @@ -36,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 c743075

Please sign in to comment.