Skip to content

docs(conf): fix class signatures, defaults, aenum names, table ids and viewcode's index (#1858, #1859, #1860, #1861, #1862, #1863) - #1881

Open
JarryShaw wants to merge 3 commits into
mainfrom
docs/1858-conf-rendering
Open

JarryShaw wants to merge 3 commits into
mainfrom
docs/1858-conf-rendering

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

Please follow the guide below

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • fix — corrects a defect
  • feat — adds a feature
  • perf — changes performance, not behaviour
  • refactor — changes neither behaviour nor performance
  • test — tests only
  • docs — documentation only
  • ci — workflows or build tooling
  • release — bumps the version or rolls up a distribution
  • chore — anything else

Stacked on #1877. It contains #1877's commit until that merges, so merge #1877 first. This PR's own commit is 0f93ff5cf.

All six fixes are in docs/source/conf.py. The figures below are from builds under the pinned sphinx-autodoc-typehints 3.15.0, comparing #1877's head with this commit.

Worth a look. To restore class parameter types in docstrings under 3.15.0, read_constructor_types_from_init repoints the library's private constructor_name. It is a separable hunk if patching the library is unwanted.

Both builds finish with 0 warnings. Each new tests/project module fails with its fix reverted. Full tests/project: 1016 passed, 7 skipped.

Closes #1858
Closes #1859
Closes #1860
Closes #1861
Closes #1862
Closes #1863

- Pin sphinx-autodoc-typehints to 3.15.0 in docs/requirements.txt.
- Import resolve_type_guarded_imports from _resolve from 3.14 on and from
  _resolver before it, chosen by the installed release, so each branch is a
  plain import that still fails loudly if the private API moves again.
- From 3.14 the library records a module's TYPE_CHECKING names instead of
  binding them, so Sphinx's own signature introspection lost them and schema
  signatures linked the wrong _VT; bind_guarded_names binds them again.
- Run bind_type_checking_names on env-before-read-docs, after the library
  clears its guard record there.
- Connect claim_attribute_signature only before 3.14, whose handler no longer
  returns a signature for an attribute.
- Add tests/project/test_docs_typehints_pin_1856_unit.py.

Closes #1856
@JarryShaw JarryShaw added docs Pull requests that change documentation only (docs: subject prefix) review: pending No verdict for the current head - never reviewed, or the head moved since the last one review: running A cross-review is in flight against the current head - no verdict yet and removed review: pending No verdict for the current head - never reviewed, or the head moved since the last one labels Oct 17, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: NEEDS CHANGES at 0f93ff5cf. A Sonnet cross-review confirmed every load-bearing claim. The only required changes are three counts this PR adds to prose:

  1. docs/source/conf.py:960: "its two modules that read it". Drop the number.
  2. docs/source/conf.py:981: "id9 to id13 on const/reg.html". That id range is generated by the build and goes stale when the page changes. Describe the titled tables instead.
  3. tests/project/test_docs_class_signature_1860_unit.py:216: "Both modules…". Rephrase without a count.

What the review confirmed:

  • Restored signatures are correct. Every restored signature uses the function cls.__init__ actually resolves to, and real constructions accept or reject arguments as the signatures say. Classes without a Python __new__ are untouched.
  • The private patch is safe. read_constructor_types_from_init is gated on the typehints release. If a release renames the private attribute, it raises at builder-inited rather than patching nothing. typehints 3.16.0 changes nothing relevant.
  • The tests are real. Each of the six fixes, reverted on its own, fails its test on a real assertion.
  • The rendering fixes reproduce. In an independent 3.15.0 build (Python 3.14 and 3.15, also with typehints 3.16.0) there are 0 warnings, catch-alls fall from 991 to 71, and the duplicate ids, IntEnum | IntEnum and the builtins.html link are all gone. tests/project: 1018 passed, 5 skipped.

Optional: hidden_init's non-pass-through __new__ branch is not pinned by any test, and the pre-3.14 typehints_constructor_name fallback is never used. My description was also loose: the 71 remaining catch-alls include FieldBase/NoValueField, whose own __init__ takes *args, **kwargs.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed review: running A cross-review is in flight against the current head - no verdict yet review: needs-changes Cross-review at the current head says changes are required; see the verdict comment labels Oct 17, 2026
@JarryShaw
JarryShaw force-pushed the docs/1858-conf-rendering branch from 0f93ff5 to 3cabc14 Compare October 17, 2026 01:34
@JarryShaw JarryShaw added the review: running A cross-review is in flight against the current head - no verdict yet label Oct 17, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at 3cabc1465. The Sonnet reviewer re-checked the changes since 0f93ff5cf.

  • The three counts are gone, and a scan of the whole PR finds no other counted number in its prose.
  • test_new_with_parameters_is_left_to_autodoc fails when hidden_init's non-pass-through __new__ branch is removed, so that branch is now covered.
  • Removing the pre-3.14 fallback is safe. The names it defined are reached only through setup's 3.14-and-later branch. Under typehints 3.13.6, conf.py loads, setup() runs and a full docs build succeeds, with no NameError.
  • Each test_docs_*_18xx_unit file passes on its own, under typehints 3.15.0 and under 3.13.6.

Merge #1877 first: this PR is stacked on it.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 17, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

what about we pin the typehints version so we dont need the branching?

@JarryShaw

Copy link
Copy Markdown
Owner Author

Agreed. docs/requirements.txt already pins 3.15.0 exactly (#1877). The branching only exists for environments that install the unpinned sphinx-autodoc-typehints from the docs extra in pyproject.toml, such as an older local venv in which tests/project loads conf.py.

The plan:

  • Pin the docs extra to the same release, with a test that the two pins agree.
  • Drop every release branch from conf.py: docs(conf): build with sphinx-autodoc-typehints 3.15.0 (#1856) #1877's _resolver fallback, and this PR's pre-3.14 paths.
  • Make the conf.py tests skip, with a clear reason, when the installed release isn't the pinned one, instead of carrying a code path for it.

A worker will add this to #1877 and rebase this PR onto it. Both review labels reset when the new heads land.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed review: good-to-go Cross-review at the current head says ready; CI state is separate labels Oct 17, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 17, 2026
@JarryShaw
JarryShaw force-pushed the docs/1858-conf-rendering branch from 3cabc14 to 8c796f6 Compare October 17, 2026 02:35
@JarryShaw JarryShaw added review: running A cross-review is in flight against the current head - no verdict yet and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment labels Oct 17, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: NEEDS CHANGES at 8c796f6c2. The rebase removes every release branch. The new furo provider and HAS_FURO exclusion fix the tier-guard failure that the earlier head 3cabc1465 would have hit (18 failed there, 111 passed now). Every test_docs_* file passes under 3.15.0 and skips cleanly under 3.13.6. A 3.15.0 docs build gives 0 warnings, and the #1858, #1860, #1861, #1862 and #1863 fixes show in the HTML.

One required change, the same as on #1877. The HAS_FURO reason (tests/_dependency_gates.py:~652) repeats that the docs extra is one "which only deploy-pages.yml installs". No workflow installs the docs extra: deploy-pages installs furo through docs/requirements.txt.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 17, 2026
…1856)

- Pin sphinx-autodoc-typehints in the docs extra to the release
  docs/requirements.txt pins, so `pip install -e .[docs]` installs what the
  docs build runs.
- Import its private modules unconditionally in conf.py, and drop the
  release check, the pre-3.14 fallbacks and claim_attribute_signature, which
  only an older release needed.
- Gate every test that loads conf.py on HAS_SPHINX, which now also requires
  the pinned release and skips with a message saying which condition failed.
- Add a test that the docs extra and docs/requirements.txt pin the same
  release, and update the HAS_SPHINX exclusion's reason.

Closes #1856
…d viewcode's index (#1858, #1859, #1860, #1861, #1862, #1863)

- Name aenum classes aenum.X through a typehints_formatter, so a union with
  the stdlib namesake no longer reads IntEnum | IntEnum (#1858).
- Turn on autodoc_preserve_defaults, and name a class that a default reaches
  through a private import alias by its own name (#1859).
- Give a class whose __init__ a pass-through or deeper __new__ hides from
  autodoc that __init__'s parameters, and have sphinx-autodoc-typehints read
  the class's parameter types from it too (#1860).
- Take a wrapped table's ids off furo's table-wrapper container (#1861).
- Give every enumeration the (*values) signature (#1862).
- Keep viewcode on the module binding an alias that reports builtins (#1863).
- Add a tests/project unit test per issue, gated on the pinned release, and
  register their furo gate in tests/_dependency_gates.py.

Closes #1858
Closes #1859
Closes #1860
Closes #1861
Closes #1862
Closes #1863
@JarryShaw
JarryShaw force-pushed the docs/1858-conf-rendering branch from 8c796f6 to ec97be1 Compare October 17, 2026 02:56
@JarryShaw JarryShaw added review: running A cross-review is in flight against the current head - no verdict yet and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment labels Oct 17, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at ec97be1e0. This is the rebase onto #1877's 57922c032. The only change is in tests/_dependency_gates.py: the HAS_SPHINX issue list now names #1858–#1863 and the enum-value hook, which the reviewer checked against the gated modules, and the HAS_FURO reason is corrected the same way as #1877's. test_tier_guard.py gives 111 passed.

Merge #1877 first.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 17, 2026
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Coverage: 90.05% (unit tier, Python 3.15, ec97be1e0, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 2 20 2 96.77%
pcapkit/const 19595 881 2618 867 92.11%
pcapkit/corekit 2462 69 780 35 96.55%
pcapkit/dumpkit 276 3 100 3 98.40%
pcapkit/foundation 2914 164 1016 34 93.59%
pcapkit/interface 138 7 52 5 93.68%
pcapkit/protocols 17406 224 4580 189 98.10%
pcapkit/toolkit 872 177 298 8 77.18%
pcapkit/utilities 512 2 158 4 99.10%
pcapkit/vendor 4407 2342 1010 157 43.27%

Per-file detail: the coverage-html artifact of this run.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment