ConfigArgParse icon indicating copy to clipboard operation
ConfigArgParse copied to clipboard

Updates toml library

Open kingbuzzman opened this issue 6 months ago • 9 comments

Depends on:

  • https://github.com/bw2/ConfigArgParse/pull/316
  • https://github.com/bw2/ConfigArgParse/pull/324

  • Updates toml lib
    • Uses the latest and greatest first, and fallbacks to tomli if its not there
  • Increases baseline test coverage by 6%

kingbuzzman avatar Jun 09 '25 11:06 kingbuzzman

Fully tested. Also increases the coverage from 85% (master) to 91%

kingbuzzman avatar Jun 16 '25 07:06 kingbuzzman

Also, please. I need this for another project, can this be released as soon as possible? 1.7.2 or 1.8.0?

kingbuzzman avatar Jun 16 '25 07:06 kingbuzzman

Looks fine to me. @tristanlatr @tbooth @agyoungs any objections to this and doing another release?

bw2 avatar Jun 16 '25 21:06 bw2

Looks fine to me. @tristanlatr @tbooth @agyoungs any objections to this and doing another release?

Thanks for the ping. I'll have time in a day or two to look at this unless someone beats me to it

agyoungs avatar Jun 16 '25 22:06 agyoungs

The switch to the new tomllib with a fallback to tomli makes sense.

However, I'll note that this PR introduces a dependency on the pytest module, which was not necessary to run the test suite in the past. Also the new tests are written in the pytest style, using @pytest.fixture decorators and bare assert statements rather than self.assertEqual() and friends. This is at odds with all the existing tests.

Personally I find the pytest approach hard to read and at odds with the "explicit is better than implicit" maxim of Python.

I think if there is a decision to move to this style of tests it should be all or nothing, and not just introduced on-the-fly within this PR. Or else, these new tests could very easily be written without the need for pytest.

tbooth avatar Jun 20 '25 16:06 tbooth

Speaking as a pytest dev member -- well you know my bias.. I'm very pro-pytest.

kingbuzzman avatar Jun 20 '25 17:06 kingbuzzman

@kingbuzzman I appreciate @tbooth 's point, and looking at this again, I agree that we should avoid heterogeneous testing styles where possible. Would you be up for switching this to the same style as existing tests?

bw2 avatar Jun 24 '25 12:06 bw2

I'm looking to put my money where my mouth is and re-write the tests without using pytest myself. It's a useful exercise as in the process I'm uncovering some issues. Specifically, if I comment out line 1844 in tests/test_configargparse.py (ie. the line that adds configargparse.TomlConfigParser(['section']), to the composite parser) then all the tests still pass.

That can't be right!

tbooth avatar Jun 24 '25 17:06 tbooth

Also, if I switch back to using the old import toml and run these new tests then all the tests still pass (if I change 'rb' to 'r' when opening the toml files in the tests), so what are we actually gaining from this change? I think we need a test or two to demonstrate why the old code is inadequate, not just to show that the new change doesn't break anything.

tbooth avatar Jun 25 '25 08:06 tbooth