Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: #281: Fixes for lists expansion operator (+=) #290

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

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.

None yet

2 participants