Skip to content

Invalid serialization after removal of array item part deux #408

@DimmaDont

Description

@DimmaDont

Removal of items from an array may leave the comma:

>>> from tomlkit import parse
>>> doc = parse('''x = [
... "one" # comment one
... , # comment two
... ]''')
>>> print(doc)
{'x': [
    (<Whitespace '\n'>, 'one', <Comment 'comment one'>),
    (<Whitespace '\n'>, <Null>, <Whitespace ','>, <Comment 'comment two'>),
    (<Whitespace '\n'>,)
]}
>>> doc["x"].remove('one')
>>> print(doc)
{'x': [
    (<Whitespace '\n'>, <Null>, <Whitespace ','>, <Comment 'comment two'>),
    (<Whitespace '\n'>,)
]}
>>> print(doc.as_string())
x = [
, # comment two
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions