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
{{ message }}
Repository navigation
--toml crashes with AttributeError: 'list' object has no attribute 'items' on a pyproject.toml with an array-of-tables directly under [tool] (e.g. [[tool.dynamic-metadata]]) #3969
read_dict expects a {section: {key: value}} mapping, but a [[tool.dynamic-metadata]] entry makes tool.dynamic-metadata a list, so read_dict fails when it does keys.items() on that value. codespell should only read the [tool.codespell] section, not its sibling tables.
This is distinct from #3852: there the user passed --config (INI-only) instead of --toml, and the array was [[tool.uv.index]], which is nested under tool.uv (a dict) and so does not trip read_dict. Here the correct --toml flag is used and the array sits directly under [tool].
Affected versions
2.4.1, 2.4.2 (latest), and current main — the config.read_dict(data) line in parse_options is unchanged across all of them.
(codespell also auto-reads ./pyproject.toml, so plain codespell hello.txt from the project directory crashes the same way, even without --toml.)
Actual behavior
Traceback (most recent call last):
...
File ".../codespell_lib/_codespell.py", line 664, in parse_options
config.read_dict(data)
File ".../configparser.py", line 763, in read_dict
for key, value in keys.items():
AttributeError: 'list' object has no attribute 'items'
Expected behavior
codespell reads the [tool.codespell] settings and reports the misspelling (hte -> the), ignoring the unrelated [[tool.dynamic-metadata]] table.
Why this matters now
[[tool.dynamic-metadata]] is emitted by every scikit-build-core >= 1.0 project (the standard dynamic-metadata table). Any such project that runs codespell against its pyproject.toml — the common case — hits this. We ran into it while migrating PyTorch's build system to scikit-build-core 1.0.
Suggested fix
In parse_options, pass only the codespell section to read_dict rather than the whole [tool] table:
Activity
DimitriPapadopoulos commentedon Jul 8, 2026
Thanks for the fix. Would you like to provide a PR?
It might be worth to exit gracefully even with
[[tool.codespell]], just in case...Migrate build system from setuptools to scikit-build-core (#180247)
Migrate build system from setuptools to scikit-build-core (pytorch#18…
Migrate build system from setuptools to scikit-build-core (pytorch#18…
Migrate build system from setuptools to scikit-build-core (pytorch#18…
Migrate build system from setuptools to scikit-build-core (pytorch#18…