You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you remove an element from an array, tomlkit then places the array closing bracket on the previous line.
If the previous line had a comment, this is now invalid toml syntax.
The most elegant solution feels like it would be to make sure that closing bracket doesn't get placed on the end of the preceding line if it was not already there.
Reproduction script
importtomlkit# Some initial toml content with an item to be removedINITIAL_CONTENT="""[info]status = [ 1, # Open 2, # In-progress 3, # Closed 4, # Useless-status]"""# This would be perfectEXPECTED_RESULT="""[info]status = [ 1, # Open 2, # In-progress 3, # Closed # Useless-status]"""# This causes a toml syntax error# The closing bracket is behind a commentACTUAL_RESULT="""[info]status = [ 1, # Open 2, # In-progress 3, # Closed # Useless-status]"""data=tomlkit.loads(INITIAL_CONTENT)
# Remove the unnecessary item from the status listdata["info"]["status"].pop() # type: ignoreresult=tomlkit.dumps(data)
# SucceedsassertACTUAL_RESULT==result, "Actual content didn't match"# FailsassertEXPECTED_RESULT==result, "Expected content didn't match"
System information
Python version: 3.10.4
Tomlkit version: 0.11.1
OS: Arch Linux 5.15.45-1-lts
The text was updated successfully, but these errors were encountered:
Details
When you remove an element from an array, tomlkit then places the array closing bracket on the previous line.
If the previous line had a comment, this is now invalid toml syntax.
The most elegant solution feels like it would be to make sure that closing bracket doesn't get placed on the end of the preceding line if it was not already there.
Reproduction script
System information
Python version: 3.10.4
Tomlkit version: 0.11.1
OS: Arch Linux 5.15.45-1-lts
The text was updated successfully, but these errors were encountered: