Skip to content

Preserve valueless INI options when decoding - #618

Merged
fabiocaccamo merged 1 commit into
fabiocaccamo:mainfrom
ac1982:fix/ini-valueless-options
Oct 9, 2026
Merged

fabiocaccamo merged 1 commit into
fabiocaccamo:mainfrom
ac1982:fix/ini-valueless-options

Conversation

@ac1982

@ac1982 ac1982 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Describe your changes

Loading [app]\nflag\ncount = 2\n with allow_no_value=True currently raises ValueError: the INI serializer attempts int(None) after configparser accepts the valueless option. Preserve None before trying numeric/boolean conversions, including defaults inherited by sections.

Tests cover valueless section/default options, the constructor and from_ini(), empty strings versus missing values, ordinary typed values, and rejection when allow_no_value is omitted or false.

Related issue

Fixes #617.

All-state searches for allow_no_value found no matching issue or PR. Related INI changes #265 (case handling) and #289 (nested structures) do not address this conversion failure.

Validation

Linux, Python 3.12.15, dependencies from requirements.txt and requirements-test.txt:

  • Before the fix: INI module runs 19 tests with two errors from the new regressions.
  • After the fix: coverage run --source=benedict -m unittest runs 920 tests, 919 pass and 1 skips; total coverage 98%.
  • pre-commit run --all-files passes all configured hooks, including Ruff 0.16.9 and mypy 2.3.1.
  • Clean main baseline: 917 tests, 916 pass and the same one skips.
  • Other Python versions and operating systems remain for CI. This change covers decoding; INI serialization is unchanged.

Checklist before requesting a review

  • I have performed a self-review of my code (Codex review; no human review claimed).
  • I have added tests for the proposed changes.
  • I have run the tests and there are not errors (one existing skip, noted above).

AI disclosure: OpenAI Codex investigated and reproduced the bug, prepared the code/tests, reviewed the final diff, ran verification, and drafted this description.

@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.52%. Comparing base (7c7be21) to head (5f6214a).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #618   +/-   ##
=======================================
  Coverage   98.52%   98.52%           
=======================================
  Files          64       64           
  Lines        2437     2439    +2     
=======================================
+ Hits         2401     2403    +2     
  Misses         36       36           
Flag Coverage Δ
unittests 98.52% <100.00%> (+<0.01%) ⬆️

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fabiocaccamo
fabiocaccamo merged commit d36e8d3 into fabiocaccamo:main Oct 9, 2026
18 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.

from_ini rejects valueless options with allow_no_value=True

2 participants