Skip to content

Commit a8cfb2f

Browse files
sethfitzvcschapp
authored andcommitted
style: single backticks in docstrings
Replace rST-style double backticks with single backticks across docstrings to match project convention. Preserve double backticks where the wrapped text itself contains backtick characters (literal markdown syntax examples). Fix D301 in type_format.py with a raw docstring for backslash content. Signed-off-by: Seth Fitzsimmons <sethfitz@amazon.com>
1 parent f2aea81 commit a8cfb2f

12 files changed

Lines changed: 64 additions & 64 deletions

File tree

packages/overture-schema-codegen/src/overture/schema/codegen/extraction/examples.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ def _inject_literal_fields(
4141
) -> dict[str, Any]:
4242
"""Inject single-value Literal field defaults missing from *data*.
4343
44-
Inspects *model_fields_dict* for fields with single-value ``Literal``
44+
Inspects *model_fields_dict* for fields with single-value `Literal`
4545
annotations. For each field missing from *data*, injects the literal
46-
value using the field's ``validation_alias`` (if set), falling back
47-
to ``alias``, then to the field name.
46+
value using the field's `validation_alias` (if set), falling back
47+
to `alias`, then to the field name.
4848
4949
Returns a new dict; the original is not mutated.
5050
"""
@@ -149,11 +149,11 @@ def sort_key(row: tuple[str, Any]) -> int:
149149

150150

151151
def _structured_fields(value: object) -> list[tuple[str, Any]] | None:
152-
"""Extract named fields from ``__slots__``-based types like BBox.
152+
"""Extract named fields from `__slots__`-based types like BBox.
153153
154-
Returns a list of ``(name, value)`` pairs for types that expose
155-
public properties backed by private slots (``_name`` -> ``name``).
156-
Returns ``None`` for types without this pattern.
154+
Returns a list of `(name, value)` pairs for types that expose
155+
public properties backed by private slots (`_name` -> `name`).
156+
Returns `None` for types without this pattern.
157157
"""
158158
cls = type(value)
159159
slots = getattr(cls, "__slots__", ())
@@ -238,9 +238,9 @@ def augment_missing_fields(
238238
) -> list[tuple[str, Any]]:
239239
"""Add (name, None) entries for fields absent from *rows*.
240240
241-
Compares base field names (via ``extract_base_field``) against
241+
Compares base field names (via `extract_base_field`) against
242242
*field_names*. Fields in *field_names* not represented in *rows*
243-
are appended as ``(name, None)``. Handles dot-notation and bracket-
243+
are appended as `(name, None)`. Handles dot-notation and bracket-
244244
notation keys correctly.
245245
246246
Parameters
@@ -267,7 +267,7 @@ def load_examples_from_toml(
267267
pyproject_path: Path,
268268
model_name: str,
269269
) -> list[dict[str, Any]]:
270-
"""Load ``[examples.<model_name>]`` from a pyproject.toml file."""
270+
"""Load `[examples.<model_name>]` from a pyproject.toml file."""
271271
with pyproject_path.open("rb") as f:
272272
data = tomllib.load(f)
273273

packages/overture-schema-codegen/src/overture/schema/codegen/extraction/model_extraction.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
def resolve_field_alias(field_name: str, field_info: FieldInfo) -> str:
2525
"""Return the data-dict key for a Pydantic field.
2626
27-
Prefers ``validation_alias``, falls back to ``alias``, then the
27+
Prefers `validation_alias`, falls back to `alias`, then the
2828
Python field name. Only string aliases are supported; AliasPath
2929
and AliasChoices are ignored.
3030
"""
@@ -153,10 +153,10 @@ def expand_model_tree(
153153
) -> FeatureSpec:
154154
"""Populate model references on MODEL-kind fields, recursively.
155155
156-
Walks *spec*'s fields and sets ``field.model`` for fields whose type
156+
Walks *spec*'s fields and sets `field.model` for fields whose type
157157
is a Pydantic model. Uses *cache* to reuse already-extracted ModelSpecs
158158
and detect shared references. Marks fields whose model creates a cycle
159-
in the ancestor chain with ``starts_cycle=True``.
159+
in the ancestor chain with `starts_cycle=True`.
160160
161161
Mutates *spec* in place and returns it.
162162
"""

packages/overture-schema-codegen/src/overture/schema/codegen/extraction/specs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class TypeIdentity:
3939
4040
Pairs a unique Python object (class, NewType callable, or union
4141
annotation) with its display name. Equality and hashing delegate
42-
to ``obj`` identity so registry lookups work regardless of how
42+
to `obj` identity so registry lookups work regardless of how
4343
the display name was derived.
4444
"""
4545

@@ -65,12 +65,12 @@ def module(self) -> str:
6565

6666

6767
class _SourceTypeIdentityMixin:
68-
"""Mixin providing ``identity`` from ``source_type`` and ``name``.
68+
"""Mixin providing `identity` from `source_type` and `name`.
6969
7070
Shared by EnumSpec, ModelSpec, NewTypeSpec, and PydanticTypeSpec --
71-
each has a ``source_type`` (the Python class/callable) and a ``name``.
72-
UnionSpec uses ``source_annotation`` instead, so it defines its
73-
own ``identity``.
71+
each has a `source_type` (the Python class/callable) and a `name`.
72+
UnionSpec uses `source_annotation` instead, so it defines its
73+
own `identity`.
7474
"""
7575

7676
source_type: object | None
@@ -225,7 +225,7 @@ def docs_url(self) -> str:
225225

226226

227227
def is_pydantic_sourced(source_type: type | None) -> bool:
228-
"""Check whether *source_type* originates from the ``pydantic`` package."""
228+
"""Check whether *source_type* originates from the `pydantic` package."""
229229
return getattr(source_type, "__module__", "").startswith("pydantic")
230230

231231

packages/overture-schema-codegen/src/overture/schema/codegen/extraction/type_analyzer.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ def walk_type_info(ti: TypeInfo, visitor: Callable[[TypeInfo], None]) -> None:
7979
"""Call *visitor* on *ti*, then recurse into dict key/value types.
8080
8181
Captures the shared recursive descent pattern used by type collection
82-
and reverse reference computation. Union members are ``type`` objects
83-
(not ``TypeInfo``), so callers handle them directly.
82+
and reverse reference computation. Union members are `type` objects
83+
(not `TypeInfo`), so callers handle them directly.
8484
"""
8585
visitor(ti)
8686
if ti.dict_key_type is not None:
@@ -108,13 +108,13 @@ class _UnwrapState:
108108
"""Accumulated state from iterative type unwrapping.
109109
110110
Tracks NewType names and refs during unwrapping:
111-
- ``outermost_newtype_name`` / ``outermost_newtype_ref``: the first
112-
NewType encountered, exposed as ``TypeInfo.newtype_name`` / ``newtype_ref``.
113-
- ``last_newtype_name``: the most recently entered NewType name, used
114-
as the resolved ``base_type`` for the terminal type.
115-
- ``last_newtype_ref``: the most recently entered NewType callable,
111+
- `outermost_newtype_name` / `outermost_newtype_ref`: the first
112+
NewType encountered, exposed as `TypeInfo.newtype_name` / `newtype_ref`.
113+
- `last_newtype_name`: the most recently entered NewType name, used
114+
as the resolved `base_type` for the terminal type.
115+
- `last_newtype_ref`: the most recently entered NewType callable,
116116
used as constraint provenance (which NewType contributed each constraint).
117-
- ``newtype_outer_list_depth``: list layers accumulated before entering
117+
- `newtype_outer_list_depth`: list layers accumulated before entering
118118
the outermost NewType boundary.
119119
"""
120120

@@ -329,7 +329,7 @@ def single_literal_value(annotation: object) -> object | None:
329329
Delegates to analyze_type for all unwrapping, then checks
330330
whether the result is a single-value Literal. Multi-value
331331
Literals return None — callers needing all values should use
332-
``analyze_type`` and read ``literal_values`` directly.
332+
`analyze_type` and read `literal_values` directly.
333333
"""
334334
try:
335335
ti = analyze_type(annotation)

packages/overture-schema-codegen/src/overture/schema/codegen/layout/module_layout.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
def _split_entry_point(entry_point_path: str) -> tuple[str, str]:
28-
"""Split ``"module.path:ClassName"`` into its two parts.
28+
"""Split `"module.path:ClassName"` into its two parts.
2929
3030
>>> _split_entry_point("overture.schema.buildings:Building")
3131
('overture.schema.buildings', 'Building')
@@ -98,7 +98,7 @@ def is_package_module(
9898
) -> bool:
9999
"""Check whether a module is a package (directory) or a file module.
100100
101-
Packages have ``__path__``; file modules do not (PEP 302).
101+
Packages have `__path__`; file modules do not (PEP 302).
102102
"""
103103
registry: Mapping[str, object] = (
104104
module_registry if module_registry is not None else sys.modules
@@ -134,7 +134,7 @@ def compute_output_dir(
134134
"""Compute output directory for a module, mirroring package structure.
135135
136136
File modules drop their last component (the .py filename).
137-
Packages keep all components. Returns ``PurePosixPath(".")`` for
137+
Packages keep all components. Returns `PurePosixPath(".")` for
138138
the root directory.
139139
"""
140140
relpath = module_relpath(module, schema_root)

packages/overture-schema-codegen/src/overture/schema/codegen/markdown/link_computation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _is_normalized(path: PurePosixPath) -> bool:
3939
def relative_link(source: PurePosixPath, target: PurePosixPath) -> str:
4040
"""Compute a relative path from source file to target file.
4141
42-
Both paths must be normalized (no ``..`` components) and relative
42+
Both paths must be normalized (no `..` components) and relative
4343
to the same output root.
4444
"""
4545
if not _is_normalized(source):

packages/overture-schema-codegen/src/overture/schema/codegen/markdown/path_assignment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ def _aggregate_page_entries(
9595
def _nest_under_types(
9696
output_dir: PurePosixPath, feature_dirs: set[PurePosixPath]
9797
) -> PurePosixPath:
98-
"""Insert ``types/`` after the feature directory portion.
98+
"""Insert `types/` after the feature directory portion.
9999
100100
If *output_dir* equals or is a subdirectory of a feature directory,
101-
returns a path with ``types/`` inserted after the feature directory.
101+
returns a path with `types/` inserted after the feature directory.
102102
Otherwise returns *output_dir* unchanged.
103103
"""
104104
for fd in sorted(feature_dirs, key=lambda p: len(p.parts), reverse=True):

packages/overture-schema-codegen/src/overture/schema/codegen/markdown/renderer.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@
6565
def _linkify_bare_urls(text: str) -> str:
6666
"""Wrap bare URLs in Markdown link syntax.
6767
68-
Turns ``www.example.com`` into ``[www.example.com](https://www.example.com)``
69-
and ``https://example.com`` into ``[https://example.com](https://example.com)``.
70-
URLs already inside ``[text](url)`` or backtick code spans are left
71-
untouched. Trailing sentence punctuation (``.``, ``,``, etc.) is excluded
68+
Turns `www.example.com` into `[www.example.com](https://www.example.com)`
69+
and `https://example.com` into `[https://example.com](https://example.com)`.
70+
URLs already inside `[text](url)` or backtick code spans are left
71+
untouched. Trailing sentence punctuation (`.`, `,`, etc.) is excluded
7272
from the link.
7373
7474
Two-pass approach: extract code spans first, linkify the remaining
@@ -118,7 +118,7 @@ def _get_jinja_env() -> Environment:
118118
class _FieldRow(TypedDict):
119119
"""Template context for a single field table row.
120120
121-
``pre_formatted`` indicates the ``name`` already contains backticks
121+
`pre_formatted` indicates the `name` already contains backticks
122122
and variant tags, so the template should render it verbatim.
123123
"""
124124

@@ -135,7 +135,7 @@ def _unwrap_paragraphs(text: str) -> str:
135135
r"""Unwrap hard-wrapped lines within paragraphs, preserving paragraph breaks.
136136
137137
Splits on blank lines (paragraph boundaries), replaces single newlines
138-
within each paragraph with spaces, then rejoins with ``\n\n``.
138+
within each paragraph with spaces, then rejoins with `\n\n`.
139139
Matches markdown's treatment of newlines within paragraphs.
140140
"""
141141
paragraphs = _PARAGRAPH_BREAK_RE.split(text)
@@ -146,8 +146,8 @@ def _sanitize_for_table_cell(text: str) -> str:
146146
"""Sanitize text for embedding in a markdown table cell.
147147
148148
Unwraps within-paragraph newlines to spaces, then converts paragraph
149-
breaks to ``<br/><br/>``. Escapes pipe characters for table safety.
150-
Uses ``<br/>`` (not ``<br>``) for MDX/Docusaurus compatibility.
149+
breaks to `<br/><br/>`. Escapes pipe characters for table safety.
150+
Uses `<br/>` (not `<br>`) for MDX/Docusaurus compatibility.
151151
"""
152152
text = text.strip()
153153
text = _unwrap_paragraphs(text)
@@ -156,7 +156,7 @@ def _sanitize_for_table_cell(text: str) -> str:
156156

157157

158158
def _truncate(text: str) -> str:
159-
"""Truncate text to ``_EXAMPLE_TRUNCATION_LIMIT`` chars, adding ellipsis."""
159+
"""Truncate text to `_EXAMPLE_TRUNCATION_LIMIT` chars, adding ellipsis."""
160160
if len(text) > _EXAMPLE_TRUNCATION_LIMIT:
161161
return text[: _EXAMPLE_TRUNCATION_LIMIT - 3] + "..."
162162
return text
@@ -255,7 +255,7 @@ def _annotate_field_constraints(
255255

256256

257257
def _expandable_list_suffix(field_spec: FieldSpec) -> str:
258-
"""Return ``"[]"`` per nesting level for list-of-model fields expanded inline."""
258+
"""Return `"[]"` per nesting level for list-of-model fields expanded inline."""
259259
if (
260260
field_spec.type_info.is_list
261261
and field_spec.model
@@ -340,7 +340,7 @@ def _short_variant_name(class_name: str, union_name: str) -> str:
340340

341341

342342
def _variant_tag(annotated: AnnotatedField, union_name: str) -> str | None:
343-
"""Return an italic variant tag like ``*(Road, Water)*``, or None for shared fields."""
343+
"""Return an italic variant tag like `*(Road, Water)*`, or None for shared fields."""
344344
if annotated.variant_sources is None:
345345
return None
346346
short_names = [
@@ -535,7 +535,7 @@ def render_pydantic_type(
535535
def _format_bound(value: int | float) -> str:
536536
"""Format a numeric bound for display.
537537
538-
Uses ``2^63`` notation for int64-scale values to avoid unreadable
538+
Uses `2^63` notation for int64-scale values to avoid unreadable
539539
numbers; otherwise formats with thousands separators for ints.
540540
"""
541541
if value == _INT64_MIN:
@@ -550,7 +550,7 @@ def _format_bound(value: int | float) -> str:
550550
def _format_interval(bounds: Interval) -> str:
551551
"""Format an Interval as a range string, or empty if unconstrained.
552552
553-
Two inclusive bounds render as ``lower to upper``. All other
553+
Two inclusive bounds render as `lower to upper`. All other
554554
combinations use explicit comparison operators so the
555555
inclusivity/exclusivity is unambiguous.
556556
"""

packages/overture-schema-codegen/src/overture/schema/codegen/markdown/type_format.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
def _code_link(name: str, href: str) -> str:
21-
"""Format a markdown link with inline-code text: [``name``](href)."""
21+
"""Format a markdown link with inline-code text: [`name`](href)."""
2222
return f"[`{name}`]({href})"
2323

2424

@@ -38,10 +38,10 @@ def resolve_type_link(identity: TypeIdentity, ctx: LinkContext | None = None) ->
3838

3939

4040
def _wrap_list_n(inner: str, depth: int) -> str:
41-
"""Wrap an inner type string in ``list<...>`` markdown syntax *depth* times.
41+
"""Wrap an inner type string in `list<...>` markdown syntax *depth* times.
4242
4343
Builds a single broken-backtick wrapper rather than nesting iteratively.
44-
Iterative nesting creates adjacent backticks (`````) that CommonMark
44+
Iterative nesting creates adjacent backticks that CommonMark
4545
interprets as multi-backtick code span delimiters.
4646
"""
4747
return f"`{'list<' * depth}`{inner}`{'>' * depth}`"
@@ -69,7 +69,7 @@ def _try_primitive_link(
6969
7070
Registered primitives (int32, Geometry) and Pydantic types (HttpUrl)
7171
can have pages in the registry. Uses the type registry display name
72-
(e.g. ``geometry`` not ``Geometry``) for the link text.
72+
(e.g. `geometry` not `Geometry`) for the link text.
7373
"""
7474
if ti.kind != TypeKind.PRIMITIVE or not ctx:
7575
return None
@@ -85,15 +85,15 @@ def _try_primitive_link(
8585
def _markdown_type_name(ti: TypeInfo) -> str:
8686
"""Return the markdown display name for a type.
8787
88-
Uses the semantic NewType name when present (e.g. ``LanguageTag``),
89-
otherwise falls back to the resolved markdown type (e.g. ``string``).
88+
Uses the semantic NewType name when present (e.g. `LanguageTag`),
89+
otherwise falls back to the resolved markdown type (e.g. `string`).
9090
"""
9191
name = ti.newtype_name if is_semantic_newtype(ti) else None
9292
return name or resolve_type_name(ti, "markdown")
9393

9494

9595
def format_dict_type(ti: TypeInfo) -> str:
96-
"""Format a dict TypeInfo as bare ``map<K, V>`` using resolved markdown names."""
96+
"""Format a dict TypeInfo as bare `map<K, V>` using resolved markdown names."""
9797
if ti.dict_key_type is None or ti.dict_value_type is None:
9898
msg = f"format_dict_type requires dict key/value types, got {ti}"
9999
raise ValueError(msg)
@@ -111,7 +111,7 @@ def _format_union_members(
111111
112112
Each member is resolved independently so members with pages get linked
113113
while others render as plain code spans. *separator* is inserted between
114-
members (default is ``\|`` for table-cell safety).
114+
members (default is `\|` for table-cell safety).
115115
"""
116116
return separator.join(resolve_type_link(TypeIdentity.of(m), ctx) for m in members)
117117

@@ -184,7 +184,7 @@ def _linked_or_backticked(ti: TypeInfo, ctx: LinkContext | None) -> tuple[str, b
184184
need broken-backtick formatting (interleaving backtick runs with
185185
linked text).
186186
187-
When ``has_link`` is True, ``formatted_string`` is a markdown link
187+
When `has_link` is True, `formatted_string` is a markdown link
188188
ready for broken-backtick container syntax. When False, it is a raw
189189
name that the caller embeds inside backticks.
190190
"""

packages/overture-schema-codegen/tests/test_example_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def mock_project(tmp_path: Path) -> Iterator[MockProject]:
196196
197197
Yields a MockProject with root, pyproject path, and mod_name.
198198
Writes a minimal pyproject.toml by default; tests can overwrite via
199-
``project.write_pyproject()``.
199+
`project.write_pyproject()`.
200200
"""
201201
root = tmp_path / "project"
202202
root.mkdir()

0 commit comments

Comments
 (0)