Skip to content

Commit e3ba73e

Browse files
committed
Respond to review
1 parent 63b47fa commit e3ba73e

7 files changed

Lines changed: 55 additions & 27 deletions

File tree

data_collections_api/dumpers.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,15 +314,19 @@ def get_str_loader(fmt: Formats):
314314

315315

316316
@overload
317-
def guess_format(path: Path) -> Formats: ...
317+
def guess_format(path: Path) -> Formats: ... # numpydoc ignore=GL08
318318

319319

320320
@overload
321-
def guess_format(path: Path, *, raise_on_invalid: Literal[True]) -> Formats: ...
321+
def guess_format(
322+
path: Path, *, raise_on_invalid: Literal[True]
323+
) -> Formats: ... # numpydoc ignore=GL08
322324

323325

324326
@overload
325-
def guess_format(path: Path, *, raise_on_invalid: Literal[False]) -> Formats | None: ...
327+
def guess_format(
328+
path: Path, *, raise_on_invalid: Literal[False]
329+
) -> Formats | None: ... # numpydoc ignore=GL08
326330

327331

328332
def guess_format(path: Path, *, raise_on_invalid: bool = True) -> Formats | None:

data_collections_api/schemas/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
@singledispatch
1818
def get_schema(schema) -> Schema:
19-
"""Get schema.
19+
"""
20+
Get schema.
2021
2122
Parameters
2223
----------

docs/source/cli.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ validate
125125

126126
Parse :option:`FILE` as this type (default: determine from suffix).
127127

128+
.. option:: -S SCHEMA, --schema SCHEMA
129+
130+
Validate against the given schema (default: :doc:`base`)
131+
128132
Validate the metadata file for a dataset before uploading.
129133

130134
``data_collections_api`` can validate your metadata file against the schema to verify the contents

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
extensions = [
3333
"numpydoc",
3434
"sphinx.ext.autodoc",
35-
"sphinx.ext.apidoc",
35+
# "sphinx.ext.apidoc",
3636
"sphinx.ext.autosummary",
3737
"sphinx.ext.intersphinx",
3838
"sphinx.ext.mathjax",

docs/source/schemas/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ This page documents the available schemas.
88
:caption: Schemas:
99

1010
base
11-

docs/source/scripts/schema_gen.py

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import argparse
66
from pathlib import Path
77
from shutil import rmtree
8+
import sys
89
from textwrap import indent
910
from typing import TYPE_CHECKING
1011

@@ -171,6 +172,42 @@ def get_filename(fmt: str, key: str) -> str:
171172
return fmt % key
172173

173174

175+
def clear_folder(folder: Path, *, force: bool = False, verbose: bool = False) -> None:
176+
"""Delete folder and create new (empty) one.
177+
178+
Parameters
179+
----------
180+
folder : Path
181+
Folder to clear.
182+
force : bool
183+
Do not ask whether to remove folder.
184+
verbose : bool
185+
Print status.
186+
"""
187+
if not folder.exists():
188+
return
189+
190+
if folder.samefile(Path.cwd()):
191+
print("Cannot clear folder as this is current working directory.")
192+
return
193+
194+
if (
195+
not force
196+
and input(f"Running this will clear {folder}, are you sure you want to continue? [y/N] ")
197+
.strip()
198+
.lower()
199+
!= "y"
200+
):
201+
print("Cancelling.")
202+
sys.exit()
203+
204+
if verbose:
205+
print(f"Deleting {folder}...")
206+
207+
rmtree(folder, ignore_errors=True)
208+
folder.mkdir()
209+
210+
174211
def main(args_in: Sequence[str] | None = None, /) -> None:
175212
"""Parse schemas and dump to file.
176213
@@ -193,25 +230,8 @@ def main(args_in: Sequence[str] | None = None, /) -> None:
193230
if args.verbose:
194231
print(f"Generating schemas for keys {', '.join(map(repr, schemas.values()))}...")
195232

196-
if args.clear and args.out_folder.exists() and not args.out_folder.samefile(Path.cwd()):
197-
if (
198-
not args.force
199-
and input(
200-
f"Running this will clear {args.out_folder},"
201-
" are you sure you want to continue? [y/N] "
202-
)
203-
.strip()
204-
.lower()
205-
!= "y"
206-
):
207-
print("Cancelling.")
208-
return
209-
210-
if args.verbose:
211-
print(f"Deleting {args.out_folder}...")
212-
213-
rmtree(args.out_folder, ignore_errors=True)
214-
args.out_folder.mkdir()
233+
if args.clear:
234+
clear_folder(args.out_folder, force=args.force, verbose=args.verbose)
215235

216236
for key, out_name in zip(schemas.values(), out_names, strict=True):
217237
out_path = args.out_folder / out_name

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ authors = [
1111
{ name = "Jas Kalayan" },
1212
{ name = "Alin M. Elena" },
1313
]
14-
requires-python = ">=3.11"
14+
requires-python = ">=3.10"
1515
classifiers = [
1616
"Programming Language :: Python",
1717
"Programming Language :: Python :: 3.10",
@@ -37,7 +37,7 @@ dependencies = [
3737
ruamel = ["ruamel.yaml>=0.17.22"]
3838
yaml = ["pyYAML>=3.13"]
3939
docs = [
40-
"sphinx>=8.2",
40+
"sphinx>=0.13.1",
4141
"sphinxcontrib-contentui<1.0.0,>=0.2.5",
4242
"furo==2025.9.25",
4343
"numpydoc>=1.9.0",

0 commit comments

Comments
 (0)