fix: read rest-section-adorns from the configuration file - #373
Open
Eljees wants to merge 1 commit into
Open
Conversation
Every command line option is read back from pyproject.toml / setup.cfg / tox.ini under its own hyphenated name -- in-place, wrap-summaries, pre-summary-space and so on. --rest-section-adorns is the one exception: it is read under rest_section_adorns, with underscores. docs/source/configuration.rst tells the user to set the ``rest-section-adorns`` option in the configuration file, so the spelling the documentation asks for is the spelling that gets dropped. The file is parsed correctly and the key does land in flargs; it is lost on the way to the argument default, which makes it silent -- no error, no warning, just the default adornment regex. Read the documented hyphenated key first and keep the underscored one as a fallback, so anyone who found the undocumented spelling by reading the source keeps working.
Contributor
Author
|
Flagging one thing so the red check is not read as mine:
I pulled both job logs and diffed them; the failing set is identical, and this branch touches none of the three. The six test jobs (3.10 through 3.14 and pypy3.9) are green. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every option is read back from the configuration file under its own hyphenated
command line name —
in-place,wrap-summaries,pre-summary-space,non-capand the rest.
--rest-section-adornsis the single exception:configuration.pyreads it as
rest_section_adorns, with underscores.docs/source/configuration.rstdocuments the hyphenated spelling:So the spelling the documentation asks for is exactly the one that gets dropped —
silently. No error, no warning; the run just uses the default adornment regex.
Reproducer
Switching the key to
rest_section_adornsin the same file makes it work, but thatspelling is not documented anywhere.
Why this looks like a typo rather than a convention
Mechanically comparing, for each
add_argumentblock, the long option name againstthe key it is read from gives one mismatch out of twenty-one:
Fix
Read the documented hyphenated key first and keep the underscored one as a fallback,
so anyone who found the undocumented spelling by reading the source keeps working.
No documentation change is needed — the docs were already right.
Tests
TestRestSectionAdornsConfigKeyintests/test_configuration_functions.py, five cases:test_hyphenated_key_is_honoredtest_hyphenated_key_wins_over_underscored_keytest_underscored_key_is_still_honoredtest_default_is_used_when_key_is_absenttest_command_line_overrides_the_configuration_fileThe last three are controls: they are green before and after, which is what shows the
change is additive rather than a behaviour swap.
Verification
Run in a clean venv with the dependency set from
[testenv]intox.ini:master(d5c7b77), whole suiteblack --check,isort --checkon the changed sourcedocformatter --check --config ./pyproject.tomlon its own sourcetests/is excluded in.pre-commit-config.yaml, so the added test block wasformatted on its own and no existing test lines are touched — the test diff is
additions only.