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

Difference in whitespace in dot notation disappears #291

Open
eugenesvk opened this issue May 20, 2023 · 0 comments
Open

Difference in whitespace in dot notation disappears #291

eugenesvk opened this issue May 20, 2023 · 0 comments

Comments

@eugenesvk
Copy link

eugenesvk commented May 20, 2023

upd: or maybe it's because

#255 (comment)

Copy and reassign breaks the structure

Then the question is how to avoid breaking the structure on copy

I'm using whitespace to vertically align some toml config and when editing said config with your great library noticed that alignment disappears, below is a small repro

content = """
[keys.a]
#    ↓ this whitespace disappears
[keys .'a'.'c']
  'd'	= 'e'
"""
def testtoml():
  from tomlkit import dumps
  from tomlkit import parse
  doc = parse(content)
  for mode in doc["keys"]: # self to self shouldn't change anything?
    doc["keys"][mode] = doc["keys"][mode]
  assert dumps(doc) == doc
  # print(dumps(doc))
testtoml()

It seems that the latter whitespace matches the first encountered in [keys.a] (if I add whitespace to [keys.a] then it propagates to further as well

Is it possible to preserve the difference in whitespace so that editing wouldn't "import" whitespace from upper keys, but retain its own?

(tested this on a master branch of your library)

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

1 participant