Skip to content

Option enumerations as StringEnum: VersionFormat, DependencyFormat, LegendStyle - #91

Merged
Paebbels merged 3 commits into
devfrom
claude/option-string-enums
Oct 28, 2026
Merged

Paebbels merged 3 commits into
devfrom
claude/option-string-enums

Conversation

@pytooling-claude

Copy link
Copy Markdown

Changes

  • pyTooling.Sphinx.DependencyTable:
    • VersionFormat and DependencyFormat are StringEnums with DEFAULT, like DuplicateFormat, DuplicateMatch and LegendPosition; their Parse is the option converter. A document writes the values in lower case with dashes:
      • :version-format: major | major-minor | major-minor-patch | all, default major-minor.
      • :dependency-format: package | package-version | package-license | package-version-license, default package-version-license.
    • The member names (MajorMinor, PackageVersionLicense) were accepted before, case-insensitive. No repository uses the two options outside this documentation.
    • Removed: DependencyTable._ParseFormatOption, the module constants DEFAULT_VERSION_FORMAT and DEFAULT_DEPENDENCY_FORMAT (VersionFormat.DEFAULT, DependencyFormat.DEFAULT), and the enumerations' __str__ returning the member's name - a member is its value now.
  • pyTooling.Sphinx:
    • LegendStyle is a StringEnum: HorizontalTable = "horizontal-table" (DEFAULT) and VerticalTable = "vertical-table". It was a Flag (Table, Horizontal, Vertical and the combinations horizontal_table/vertical_table), of which only the two combinations were ever chosen. Documents keep writing :style: vertical-table.
    • BaseDirective._ParseEnumOption is removed: its only callers were the two coverage legends. No other repository uses it.
  • pyTooling.Sphinx.CodeCoverage, pyTooling.Sphinx.DocCoverage: report:code-coverage-legend and report:doc-coverage-legend read :style: with LegendStyle.Parse and compare the member instead of testing bits.
  • A value that isn't allowed is reported by docutils as an invalid option value of the directive, with the allowed values (StringEnum.Parse's note), instead of a SphinxExtensionError while the directive runs.

Documentation

  • dependency-table: the values of :version-format: and :dependency-format:.

Unit Tests

  • tests/unit/DependencyTable.py: the defaults of VersionFormat and DependencyFormat via Parse(None); their values, and the old member spelling rejected with the allowed values (replaces the test of __str__).
  • tests/unit/Reports.py: new testsuite Coverage legend style: the default and the values, vertical_table rejected.
  • 482 tests pass locally.

Related Issues and Pull-Requests

claude-code and others added 3 commits October 28, 2026 19:31
Like DuplicateFormat, DuplicateMatch and LegendPosition: a StringEnum with
DEFAULT, whose Parse is the option converter. A document writes the values in
lower case with dashes:

  :version-format:    major | major-minor (default) | major-minor-patch | all
  :dependency-format: package | package-version | package-license |
                      package-version-license (default)

The member names (MajorMinor, PackageVersionLicense) were accepted before,
case-insensitive; no project here uses the two options outside this
documentation. DependencyTable._ParseFormatOption, its TypeVar and the module
constants DEFAULT_VERSION_FORMAT and DEFAULT_DEPENDENCY_FORMAT are removed;
the enums' __str__ returning the member name is gone, a member is its value.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
LegendStyle was a Flag (Table, Horizontal, Vertical and the combinations
horizontal_table/vertical_table), read by BaseDirective._ParseEnumOption,
which lower-cased the value and turned dashes into underscores. Only the two
combinations were ever chosen, so it is a StringEnum now, like the other
option enumerations: HorizontalTable = "horizontal-table" (DEFAULT),
VerticalTable = "vertical-table". Its Parse is the option converter of
report:code-coverage-legend and report:doc-coverage-legend; documents keep
writing ':style: vertical-table'. The directives compare the member instead
of testing bits.

Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
Its only callers were the two coverage legends, which read LegendStyle with
its Parse as option converter now. No other repository uses it. The TypeVar
_EnumType and the imports of Enum, Flag and TypeVar go with it.

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 19:34
@pytooling-claude pytooling-claude Bot added 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

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics -15 complexity · 0 duplication

Metric Results
Complexity -15
Duplication 0

View in Codacy

🟢 Coverage 83.33% diff coverage · +0.15% coverage variation

Metric Results
Coverage variation ✅ +0.15% coverage variation (-1.00%)
Diff coverage ✅ 83.33% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (c731b8b) 5236 4653 88.87%
Head commit (2323623) 5197 (-39) 4626 (-27) 89.01% (+0.15%)

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 (#91) 30 25 83.33%

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%

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 73.33333% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.14%. Comparing base (c731b8b) to head (2323623).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
pyTooling/Sphinx/CodeCoverage.py 40.00% 1 Missing and 2 partials ⚠️
pyTooling/Sphinx/DocCoverage.py 40.00% 2 Missing and 1 partial ⚠️
pyTooling/Sphinx/DependencyTable.py 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev      #91      +/-   ##
==========================================
+ Coverage   86.95%   87.14%   +0.19%     
==========================================
  Files          24       24              
  Lines        5236     5197      -39     
  Branches      839      833       -6     
==========================================
- Hits         4553     4529      -24     
+ Misses        583      571      -12     
+ Partials      100       97       -3     
Flag Coverage Δ
unittests 87.14% <73.33%> (+0.19%) ⬆️

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.

@Paebbels
Paebbels merged commit 3be6fde into dev Oct 28, 2026
51 of 53 checks passed
@Paebbels
Paebbels deleted the claude/option-string-enums branch October 28, 2026 19:48
@pytooling-claude pytooling-claude Bot mentioned this pull request Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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