TOMLKit is failing to pop a table key in some very strange circumstances.
Below is a failing example:
import tomlkit
test_toml = """
[tool.poetry]
version = "0.3.0"
[tool.uv.sources]
torch = { index = "pytorch-gpu" }
unsloth = { git = "https://github.com/unslothai/unsloth.git" }
[tool.poetry.group.dev.dependencies]
pytest = "^7.2.2"
pytest-cov = "^4.0.0"
black = "^23.1.0"
mypy = "^1.2.0"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[[tool.poetry.source]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
priority = "explicit"
"""
parsed = tomlkit.loads(test_toml)
parsed["tool"].pop("poetry")
Traceback:
Traceback (most recent call last):
File "test.py", line 28, in <module>
parsed["tool"].pop("poetry")
File "/[...]/python3.8/_collections_abc.py", line 801, in pop
del self[key]
File "/[...]/python3.8/site-packages/tomlkit/container.py", line 868, in __delitem__
del table[key]
File "/[...]/python3.8/site-packages/tomlkit/items.py", line 1502, in __delitem__
self.remove(key)
File "/[...]/python3.8/site-packages/tomlkit/items.py", line 1472, in remove
self._value.remove(key)
File "/[...]/python3.8/site-packages/tomlkit/container.py", line 352, in remove
raise NonExistentKey(key)
tomlkit.exceptions.NonExistentKey: 'Key "poetry" does not exist.'
What's strange is that if I comment out any section from the above example - it works just fine.
Python: 3.8.20
tomlkit: 0.13.2
TOMLKit is failing to pop a table key in some very strange circumstances.
Below is a failing example:
Traceback:
What's strange is that if I comment out any section from the above example - it works just fine.
Python: 3.8.20
tomlkit: 0.13.2