Skip to content

Error when removing the first element from array: AttributeError: 'NoneType' object has no attribute 's' #327

@pinal005

Description

@pinal005

seeing this edge case while removing the first element from the array:

Below code works fine if there is a space before the second element(i.e. "green" in below example) and try to remove the first element.

import tomlkit
doc = tomlkit.loads("""
[colors]
primary = ["red", "green","blue"]
""")

doc["colors"]["primary"].remove("red")

But errors out if there is no space before the second element "green"

import tomlkit
doc = tomlkit.loads("""
[colors]
primary = ["red","green","blue"]
""")
doc["colors"]["primary"].remove("red")

Error:

tomlkit/items.py", line 1415, in __delitem__
    and "\n" not in self._value[idx].indent.s
AttributeError: 'NoneType' object has no attribute 's'

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