Skip to content

docs: Document Attributes for NamedTuple and dataclass fields#548

Merged
tony merged 4 commits into
masterfrom
attributes-backfill
Jul 26, 2026
Merged

docs: Document Attributes for NamedTuple and dataclass fields#548
tony merged 4 commits into
masterfrom
attributes-backfill

Conversation

@tony

@tony tony commented Jul 25, 2026

Copy link
Copy Markdown
Member

Autodoc renders every field of a NamedTuple, dataclass, or TypedDict whether or not the docstring describes it, so fields that predate the Attributes rule reached the API reference as stubs — NamedTuple fields as "Alias for field number 0", dataclass fields bare. This adds a NumPy-style Attributes section to the classes that were missing one, covering the subprocess command mirror, the sync result types and git status/remote records, and the URL rule and parser fields. Rule's existing per-field docstrings also sat one field below what they described, pairing "Weight: Higher is more likely to win" with is_explicit; those move into the Attributes section beside the field each belongs to. Docstrings only — no code, signature, or field-order changes.

Gates run and passing: just ruff-format, just ruff, uv run mypy ., just test, just build-docs.

The docs build succeeds but now emits duplicate-object warnings for every newly documented field (duplicate object description of ..., other instance in ...), in _internal/subprocess.py, sync/base.py, sync/git.py, url/base.py, url/git.py, url/hg.py, and url/svn.py. The NumPy preprocessor emits an .. attribute:: for each entry while autodoc separately renders the same field, so both register the object. Trunk builds warning-free. Left unsuppressed here — the fix belongs in gp-sphinx and is landing there separately.

Closes #547

@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.31%. Comparing base (5663ec7) to head (bcccf11).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #548      +/-   ##
==========================================
- Coverage   61.34%   61.31%   -0.03%     
==========================================
  Files          40       40              
  Lines        6571     6566       -5     
  Branches     1104     1104              
==========================================
- Hits         4031     4026       -5     
  Misses       1946     1946              
  Partials      594      594              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tony
tony force-pushed the attributes-backfill branch from 3bb4cfb to ceb8bb1 Compare July 26, 2026 00:57
tony added 4 commits July 25, 2026 20:20
why: Autodoc renders every dataclass field, so the undocumented
Popen mirror fields shipped bare in the API reference with no hint
of their accepted values, platform scope, or what each default
means.

what:
- Document every SubprocessCommand field in an Attributes section
- Note which fields are POSIX-only or Windows-only
- Spell out the sentinel defaults (-1, (), None) and the text-mode
  interaction between text, universal_newlines, encoding, errors
why: Autodoc renders every field whether or not it is described, so
these shipped to the API reference bare, and the NamedTuple fields
shipped as "Alias for field number 0".

what:
- Document SyncError, SyncResult, and VCSLocation fields
- Document GitRemote fetch/push URL fields
- Describe GitStatus fields as the "git status --porcelain=2"
  branch headers they hold, including when each is None
why: Autodoc renders every dataclass field, so the parsed URL
fields shipped bare in the API reference. Rule's per-field
docstrings also sat one field below what they described, so
readers matched "Weight: Higher is more likely to win" to
is_explicit.

what:
- Move Rule's field docstrings into an Attributes section, paired
  with the field each describes, and cover defaults and weight
- Document the parsed fields of GitBaseURL, HgBaseURL, SvnBaseURL,
  including which sentinel each carries when a rule captures
  nothing
- Document region and rev on GitAWSCodeCommitURL, and rev on the
  pip URL parsers
why: The unreleased entry did not record that class fields now carry
descriptions where the API reference renders them.

what:
- Note the described fields under Documentation
@tony
tony force-pushed the attributes-backfill branch from bc12f17 to bcccf11 Compare July 26, 2026 01:22
@tony
tony merged commit d11545c into master Jul 26, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: Document Attributes for NamedTuple and dataclass fields

1 participant