Skip to content

dependency-table: fold duplicate dependencies; show and merge extras - #90

Merged
Paebbels merged 4 commits into
devfrom
claude/dependency-duplicates
Oct 28, 2026
Merged

Paebbels merged 4 commits into
devfrom
claude/dependency-duplicates

Conversation

@pytooling-claude

@pytooling-claude pytooling-claude Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

New Features

  • pyTooling.Sphinx.DependencyTable:
    • New option :duplicates: expanded | collapsed | reference, default collapsed: how a dependency tree shows the dependencies of a duplicate, a package whose dependencies an earlier line of the table already shows.
      • expanded shows them again, as before.
      • collapsed folds them below a marker like … same 17 dependencies as listed at sphinx, which links to the earlier line; in HTML, a click on the marker unfolds them (<details>), so the data is on the page but takes no space.
      • reference shows the marker alone.
      • LaTeX, text, manual pages and Texinfo can't unfold anything: they get the marker, without the link (new post-transform ReplaceFoldedDependencies).
    • New option :duplicate-match: exact | subset | name, default subset: when a line is a duplicate of an earlier line of the same package - the same release with the same extras, the same release with the earlier line's extras or fewer (everything it requires is shown there), or any release with any extras.
    • Which line is the original: every package of the table's first column, so a dependency the table lists in a row of its own links to that row (sphinx below sphinx_autodoc_typehints links to the row sphinx, even if the row is further down); otherwise the first line in reading order, also for a package two trees share several levels down (pydantic). A line whose dependencies the :depth: limit cut off is no original. A duplicate keeps its own line - version constraint and license -, as these differ by what requires the package.
    • A package is shown with the extras its requirement names, sorted, in the table's first column and in every line of a tree: pyTooling[dependencies], pyTooling[console,packaging,yaml].
    • The marker links to a readable ID on the original's whole table row or list item, #dependency-<entrypoint>-<package> with the extras, e.g. #dependency-documentation-requests; a second original of the same name gets -2, and the ID is registered with the document, which keeps it unique on the page. In HTML, the target row or item - the package with its dependencies - is highlighted after the jump: its background fades from Sphinx' highlight yellow to its own in 2.5 seconds, or stays highlighted if the reader's system asks for reduced motion (custom property --pyTooling-table-target-color).
    • The options are read by DuplicateFormat and DuplicateMatch, StringEnums with DEFAULT, like LegendPosition.
    • Every bullet list of a dependency tree is compact: an item with folded dependencies is more than a paragraph and a list, which would end docutils' simple list, and the theme would keep the paragraph margins of every line in it.
  • pyTooling.Sphinx.Node: new nodes FoldedDependencies (HTML <details>) and FoldedSummary (HTML <summary>), registered in NODES.

Bug Fixes

  • pyTooling.Sphinx.DependencyTable: when several statements of an entrypoint required the same package - a requirements file and a file it includes with -r, several files of files, the published requirements of several packages - the last statement replaced the earlier ones entirely, so a later pyTooling dropped the extra of an earlier pyTooling[yaml] and the table missed that extra's dependencies. The last statement's constraint is used now, with the extras of all statements, as pip installs every extra any statement names. The requirements of the requirements file model aren't changed; an extended requirement is a copy.

Documentation

  • dependency-table: options :duplicates: and :duplicate-match: with their values, the rule which line is the original, the anchors and the highlight; a paragraph on extras and on several statements of one package.
  • News: an item for duplicates and extras.

Unit Tests

  • tests/unit/DependencyTable.py:
    • New testsuite Duplicate dependencies: the defaults and option values; every list compact; readable anchors and their numbering; Expanded; a collapsed and a referenced duplicate of a row further down; a package two trees share, with the link's target; Subset and Exact with extras; another release, which only Name matches; an original cut off by the depth limit; a line without dependencies; ReplaceFoldedDependencies for formats without folding.
    • New testsuite Extras: no extras, sorted extras, merging a later statement with the earlier extras (inputs unchanged), a later statement naming all extras already, and extras across two requirements files.
    • The test table renders a package with its extras; the fake requirement interns its release, so two lines of one release share one object, as the resolver's do.
  • tests/unit/Reports.py: setup() registers ReplaceFoldedDependencies.
  • 480 tests pass locally. pyTooling.Sphinx's own documentation folds 16 duplicates (6× sphinx, 4× requests, 2× pytest, ...) to 10 readable targets; every link has a target. Its LaTeX build writes the markers as text.

Related Issues and Pull-Requests

New directive options:
* ':duplicates: Expanded | Collapsed | Reference' (default Collapsed): how a
  tree shows the dependencies of a duplicate - a package whose dependencies an
  earlier line of the table already shows. Collapsed folds them below a marker
  '... 17 dependencies, listed at sphinx' linking to that line; HTML unfolds
  them on a click (<details>, new nodes FoldedDependencies/FoldedSummary).
  Reference shows the marker alone. LaTeX, text, man and Texinfo get the
  marker without link (post-transform ReplaceFoldedDependencies).
* ':duplicate-match: Exact | Subset | Name' (default Subset): same release
  and extras / same release and the original's extras or fewer / any.

Every first-level row is an original, so a dependency listed in a row of its
own links to that row; otherwise the first line in reading order is the
original, also for a package two trees share further down. A line whose
dependencies the depth limit cut off is no original. A duplicate keeps its
own line (version constraint, license).

A package is shown with its requirement's extras, sorted:
'pyTooling[dependencies]'. Several statements of a package in one entrypoint
(files, '-r' includes, published packages, pyproject.toml) keep the last
statement's constraint with the extras of all of them, as pip does.

pyTooling.Sphinx's own documentation folds 16 duplicates; every link has a
target.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
@pytooling-claude
pytooling-claude Bot requested a review from Paebbels as a code owner October 28, 2026 16:49
@pytooling-claude pytooling-claude Bot added Bug Something isn't working Documentation Improvements or additions to documentation Enhancement New feature or request labels Oct 28, 2026
@codacy-production

codacy-production Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 9 minor

Alerts:
⚠ 9 issues (≤ 0 issues of at least minor severity)

Results:
9 new issues

Category Results
UnusedCode 1 minor
Documentation 2 minor
CodeStyle 6 minor

View in Codacy

🟢 Metrics 67 complexity · 0 duplication

Metric Results
Complexity 67
Duplication 0

View in Codacy

🟢 Coverage 86.53% diff coverage

Metric Results
Coverage variation Report missing for 2aca4691
Diff coverage ✅ 86.53% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (2aca469) Report Missing Report Missing Report Missing
Head commit (9e403f8) 5236 4653 88.87%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#90) 193 167 86.53%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.52850% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.95%. Comparing base (3920927) to head (9e403f8).
⚠️ Report is 2 commits behind head on dev.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
pyTooling/Sphinx/DependencyTable.py 87.20% 22 Missing ⚠️
pyTooling/Sphinx/HTML.py 75.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev      #90      +/-   ##
==========================================
+ Coverage   86.85%   86.95%   +0.09%     
==========================================
  Files          24       24              
  Lines        5083     5236     +153     
  Branches      814      839      +25     
==========================================
+ Hits         4415     4553     +138     
- Misses        568      583      +15     
  Partials      100      100              
Flag Coverage Δ
unittests 86.95% <86.52%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread pyTooling/Sphinx/DependencyTable.py Resolved
claude-code and others added 3 commits October 28, 2026 18:13
…items

* DuplicateFormat and DuplicateMatch are StringEnums with DEFAULT
  (Collapsed, Subset), read by their Parse as option converters, like
  LegendPosition. The option values are lower case: ':duplicates: collapsed',
  ':duplicate-match: subset'. DEFAULT_DUPLICATE_FORMAT/-MATCH are gone.
* Every bullet list of a dependency tree is marked 'compact'. docutils makes
  a list 'simple' only if each item is a paragraph and at most one list; an
  item with folded dependencies (paragraph + <details>) made the whole list
  non-simple, so the theme kept the paragraph margins of every line in it -
  the gaps around the fold and before the nested lists of its siblings.
  pyTooling.Sphinx's dependency page: all 27 trees are 'simple' now.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
The marker of a duplicate reads '… same 4 dependencies as listed at
requests' (was '… 4 dependencies, listed at requests'), so it says these are
the same dependencies as at the linked line.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
* An original's anchor is a readable ID on its whole table row or list
  item: 'dependency-<entrypoint>-<package>' with the extras, e.g.
  '#dependency-documentation-requests' (was a counted 'id7' on the text
  line). It reads well in a URL and doesn't change when something earlier on
  the page adds an ID. A second original of the same name gets '-2'; the ID
  is registered with the document, which keeps it unique on the page.
* pyTooling.css: the row or list item a marker links to ('tr:target > td',
  'li:target') is highlighted after the jump: its background fades from
  Sphinx' highlight yellow to its own in 2.5 s (no 'to' keyframe, so a
  theme's row stripe comes back). With 'prefers-reduced-motion: reduce' the
  highlight stays. Custom property '--pyTooling-table-target-color'.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
@Paebbels
Paebbels merged commit c731b8b into dev Oct 28, 2026
103 of 106 checks passed
@Paebbels
Paebbels deleted the claude/dependency-duplicates branch October 28, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Documentation Improvements or additions to documentation Enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants