Skip to content

Conversation

@USSX-Hares
Copy link
Contributor

@USSX-Hares USSX-Hares commented Sep 25, 2022

Root Casuse

Actually, the += operator took the HOCON definition too literally.
When the x += y was met, it created a substitution for x.
Then, when the entire config is read, that substitution is applied at the exact name x.
However, if x was inside a dict object, the x would not be resolved.

Changes

  • Added tests covering broken operator behavior
  • The += operator now creates a smarter substitution

ToDo:

  • Check other conditions when it may fail
  • (?) Resolve += in-place?

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.9%) to 94.294% when pulling aa133cf on USSX-Hares:bug/281-expand-list-fixes into be660de on chimpler:master.

@USSX-Hares
Copy link
Contributor Author

USSX-Hares commented Sep 25, 2022

I've found that pyhocon's implementation of the operator += diverges from the HOCON standard: in HOCON, += (1) can only be applied to arrays and (2) can only append elements to arrays, not extend arrays with the arrays.

According to https://hocon-playground.herokuapp.com/, the following configuration:

d {
    x = [1,2]
    x += [3,4]
}

resolves into the following:

d {
    x=[
        1,
        2,
        [
            3,
            4
        ]
    ]
}

@darthbear, what do you think?

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.

2 participants