Skip to content

Commit c679446

Browse files
Added docstrings
1 parent 9d0b9a4 commit c679446

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

schema_salad/python_codegen.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,10 @@ def prologue(self) -> None:
152152
from typing_extensions import Self
153153
""")
154154

155-
for parent in self.parents_map.values():
156-
self.out.write(f"import {parent}\n")
155+
if self.parents_map:
156+
self.out.write("\n")
157+
for parent in self.parents_map.values():
158+
self.out.write(f"import {parent}\n")
157159

158160
python_codegen_support: Final = (
159161
files("schema_salad").joinpath("python_codegen_support.py").read_text("UTF-8")
@@ -625,9 +627,9 @@ def declare_field(
625627
"""
626628
{spc} vocab = _vocab | loadingOptions.vocab
627629
{spc} if {safename} not in (cls.__name__, vocab.get(cls.__name__)):
628-
{spc} raise ValidationException(f"tried `{{cls.__name__}}` but")
630+
{spc} raise ValidationException(f"tried `{{cls.__name__}}` but")
629631
{spc} except ValidationException as e:
630-
{spc} raise e
632+
{spc} raise e
631633
""".format(
632634
safename=self.safe_name(name),
633635
spc=spc,

schema_salad/runtime.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""
22
Shared code for parsers generated by the Python codegen.
33
4-
See :option:`--codegen=python` & :py:mod:`python_codegen`."""
4+
See :option:`--codegen=python` & :py:mod:`python_codegen`.
5+
"""
56

67
from __future__ import annotations
78

@@ -35,6 +36,8 @@
3536

3637

3738
class LoadingOptions:
39+
"""Class that holds the state of loading a SALAD document."""
40+
3841
idx: Final[IdxType]
3942
fileuri: Final[str | None]
4043
baseuri: Final[str]
@@ -280,6 +283,7 @@ def save(
280283
base_url: str = "",
281284
relative_uris: bool = True,
282285
) -> save_type:
286+
"""Convert an object to a JSON/YAML friendly dictionary."""
283287
if isinstance(val, Saveable):
284288
return val.save(top=top, base_url=base_url, relative_uris=relative_uris)
285289
if isinstance(val, MutableSequence):

0 commit comments

Comments
 (0)