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

Is += working at all? #281

Closed
ws1088 opened this issue Feb 15, 2022 · 3 comments
Closed

Is += working at all? #281

ws1088 opened this issue Feb 15, 2022 · 3 comments

Comments

@ws1088
Copy link

ws1088 commented Feb 15, 2022

test.conf:

foo {
    baz = ["a"]
    baz += "b"
}

code:

from pyhocon import ConfigFactory
spec = ConfigFactory.parse_file('./test.conf'))
print(spec)

output:

ConfigTree([('foo', ConfigTree([('baz', ' b')]))])

I thot += will concatenate...

@USSX-Hares
Copy link
Contributor

USSX-Hares commented Sep 25, 2022

Actually, it DOES concatenate... If you create the following config, the += would work... but NOT as intended:

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

Results in:

{
  "x": [
    1,
    2
  ],
  "d": {
    "x": [
      1,
      2,
      3,
      4
    ]
  }
}

USSX-Hares pushed a commit to USSX-Hares/pyhocon that referenced this issue Sep 25, 2022
USSX-Hares pushed a commit to USSX-Hares/pyhocon that referenced this issue Sep 25, 2022
@USSX-Hares
Copy link
Contributor

Also, according to https://hocon-playground.herokuapp.com/, the += operator SHOULD NOT extend arrays, only append elements, which, ironically, pyhocon can't do.

USSX-Hares pushed a commit to USSX-Hares/pyhocon that referenced this issue Sep 26, 2022
@ws1088
Copy link
Author

ws1088 commented Oct 16, 2022

thanks!

@ws1088 ws1088 closed this as completed Oct 16, 2022
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

No branches or pull requests

2 participants