Skip to content

Commit dc57554

Browse files
committed
random docstring cleanups
1 parent 31fb9cc commit dc57554

23 files changed

+35
-55
lines changed

schema_salad/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Salad is a schema language for describing JSON or YAML structured linked data documents"""
1+
"""Salad is a schema language for describing JSON or YAML structured linked data documents."""
22

33
import logging
44
import sys

schema_salad/avro/schema.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,16 @@ def items(self) -> Schema:
422422

423423

424424
class UnionSchema(Schema):
425-
"""
426-
names is a dictionary of schema objects
427-
"""
428-
429425
def __init__(
430426
self,
431427
schemas: List[JsonDataType],
432428
names: Names,
433429
) -> None:
430+
"""
431+
Initialize a new UnionSchema.
432+
433+
:param names: a dictionary of schema objects
434+
"""
434435
# Ensure valid ctor args
435436
if names is None:
436437
raise SchemaParseException("Must provide Names.")
@@ -555,8 +556,9 @@ def get_other_props(
555556
all_props: PropsType, reserved_props: Tuple[str, ...]
556557
) -> Optional[PropsType]:
557558
"""
558-
Retrieve the non-reserved properties from a dictionary of properties
559-
@args reserved_props: The set of reserved properties to exclude
559+
Retrieve the non-reserved properties from a dictionary of properties.
560+
561+
:param reserved_props: The set of reserved properties to exclude
560562
"""
561563
if hasattr(all_props, "items") and callable(all_props.items):
562564
return {k: v for (k, v) in all_props.items() if k not in reserved_props}
@@ -567,7 +569,7 @@ def make_avsc_object(json_data: JsonDataType, names: Optional[Names] = None) ->
567569
"""
568570
Build Avro Schema from data parsed out of JSON string.
569571
570-
@arg names: A Name object (tracks seen names and default space)
572+
:param names: A Name object (tracks seen names and default space)
571573
"""
572574
if names is None:
573575
names = Names()
@@ -651,7 +653,7 @@ def make_avsc_object(json_data: JsonDataType, names: Optional[Names] = None) ->
651653

652654

653655
def is_subtype(existing: PropType, new: PropType) -> bool:
654-
"""Checks if a new type specification is compatible with an existing type spec."""
656+
"""Check if a new type specification is compatible with an existing type spec."""
655657
if existing == new:
656658
return True
657659
if isinstance(existing, list) and (new in existing):

schema_salad/codegen.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def codegen(
4141
parser_info: Optional[str] = None,
4242
) -> None:
4343
"""Generate classes with loaders for the given Schema Salad description."""
44-
4544
j = schema.extend_and_specialize(i, loader)
4645

4746
gen = None # type: Optional[CodeGenBase]

schema_salad/dlang_codegen.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def __init__(
3535

3636
def prologue(self) -> None:
3737
"""Trigger to generate the prolouge code."""
38-
3938
module_comment = []
4039

4140
if self.parser_info:
@@ -141,7 +140,7 @@ def to_doc_comment(self, doc: Union[None, str, List[str]]) -> str:
141140
for line in lines
142141
]
143142

144-
doc_lines = "\n".join((f" * {line}" for line in lines))
143+
doc_lines = "\n".join(f" * {line}" for line in lines)
145144

146145
return f"""/**
147146
{doc_lines}
@@ -239,7 +238,7 @@ def parse_record_schema(self, stype: Dict[str, Any]) -> str:
239238
if "fields" in stype:
240239
for field in stype["fields"]:
241240
field_decls.append(self.parse_record_field(field, classname))
242-
decl_str = "\n".join((textwrap.indent(f"{d}", " " * 4) for d in field_decls))
241+
decl_str = "\n".join(textwrap.indent(f"{d}", " " * 4) for d in field_decls)
243242

244243
if stype.get("documentRoot", False):
245244
doc_root_annotation = "@documentRoot "

schema_salad/dotnet_codegen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ def copy_utils_recursive(util_src: str, util_target: Path) -> None:
971971
src = src_template.safe_substitute(template_args)
972972
_ensure_directory_and_write(src_path, src)
973973

974-
for (util_src, util_target) in util_src_dirs.items():
974+
for util_src, util_target in util_src_dirs.items():
975975
copy_utils_recursive(util_src, util_target)
976976

977977
def secondaryfilesdsl_loader(self, inner: TypeDef) -> TypeDef:

schema_salad/exceptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Shared Exception classes."""
12
from typing import List, Optional, Sequence, Tuple, Union
23

34
from .sourceline import SourceLine, reflow_all, strip_duplicated_lineno
@@ -98,6 +99,7 @@ def summary(self, level: int = 0, with_bullet: bool = False) -> str:
9899
return f"{self.prefix()}{spaces}{bullet}{self.message}"
99100

100101
def __str__(self) -> str:
102+
"""Convert to a string using :py:`pretty_str`."""
101103
return str(self.pretty_str())
102104

103105
def pretty_str(self, level: int = 0) -> str:

schema_salad/java_codegen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ def expand_resource_template_to(resource: str, path: Path) -> None:
902902
"main_utils": self.main_src_dir,
903903
"test_utils": self.test_src_dir,
904904
}
905-
for (util_src, util_target) in util_src_dirs.items():
905+
for util_src, util_target in util_src_dirs.items():
906906
for util in pkg_resources.resource_listdir(__name__, f"java/{util_src}"):
907907
src_path = util_target / "utils" / util
908908
src_template = template_from_resource(os.path.join(util_src, util))

schema_salad/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def main(argsl: Optional[List[str]] = None) -> int:
266266
_logger.debug("Index is %s", list(metaschema_loader.idx.keys()))
267267
_logger.debug("Vocabulary is %s", list(metaschema_loader.vocab.keys()))
268268
return 1
269-
except (RuntimeError) as e:
269+
except RuntimeError as e:
270270
_logger.error(
271271
"Schema `%s` read error:\n%s",
272272
args.schema,

schema_salad/makedoc.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,7 @@ def markdown_list_hook(markdown, text, state):
243243

244244

245245
def patch_fenced_code(original_markdown_text: str, modified_markdown_text: str) -> str:
246-
"""
247-
Reverts fenced code fragments found in the modified contents back to their original definition.
248-
"""
246+
"""Reverts fenced code fragments found in the modified contents back to their original definition."""
249247
# Pattern inspired from 'mistune.block_parser.BlockParser.FENCED_CODE'.
250248
# However, instead of the initial ' {0,3}' part to match any indented fenced-code,
251249
# use any quantity of spaces, as long as they match at the end as well (using '\1').

schema_salad/metaschema.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747

4848

4949
class LoadingOptions:
50-
5150
idx: IdxType
5251
fileuri: Optional[str]
5352
baseuri: str
@@ -73,7 +72,6 @@ def __init__(
7372
idx: Optional[IdxType] = None,
7473
) -> None:
7574
"""Create a LoadingOptions object."""
76-
7775
self.original_doc = original_doc
7876

7977
if idx is not None:

0 commit comments

Comments
 (0)