pytest-dev / iniconfig

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

handle indented starting lines

RonnyPfannschmidt opened this issue · comments

as per pytest-dev/pytest#8923 the following is legal in setup.cfg

https://github.com/fzeiser/pytest_error_unexpected_value_continuation/blob/6bd101f89e756e961efe176c2624b5156e79d51a/setup.cfg#L16-L18

[options.extras_require]
    tests =
        pytest

a mode to handle completely indented sections should be considered

It's more tricky than it may seem at frist glance.
One approach could be to dedent all sections before processing in _parse as usual, e.g. using textwrap.dedent such that:

    [section2]
    name1=
        line1
    name2=line2

will become

[section2]
name1=
    line1
name2=line2

Then repeat the the same for all "contents" of sections, such following would be parsed just as the dedented version above.

[section2]
    name1=
        line1
    name2=line2

However, this following config file would still be invalid (and maybe it just should be invalid? -- but this should be specified somewhere):

[section2]
name1=line1
  name2=line2

thanks for elaboration

indeed, the last example should be invalid,
there will not be a dedent, but initial indent should trigger a warning

i decided to not support this at all, as its too simple to get into weird error modes