Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,11 @@ def _split_lines(self, text: str, width: int) -> List[str]:

def _toml_to_parseconfig(toml_dict: Dict[str, Any]) -> Dict[str, Any]:
"""Convert a dict read from a TOML file to the parseconfig.read_dict() format."""
return {k: "" if v is True else v for k, v in toml_dict.items() if v is not False}
return {
k: "" if v is True else ",".join(v) if isinstance(v, list) else v
for k, v in toml_dict.items()
if v is not False
}


def _supports_ansi_colors() -> bool:
Expand Down
18 changes: 16 additions & 2 deletions codespell_lib/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ def test_ill_formed_ini_config_file(
assert "ill-formed config file" in stderr


@pytest.mark.parametrize("kind", ("toml", "cfg"))
@pytest.mark.parametrize("kind", ("cfg", "toml", "toml_list"))
def test_config_toml(
tmp_path: Path,
capsys: pytest.CaptureFixture[str],
Expand Down Expand Up @@ -1182,7 +1182,7 @@ def test_config_toml(
count =
"""
)
else:
elif kind == "toml":
assert kind == "toml"
if sys.version_info < (3, 11):
pytest.importorskip("tomli")
Expand All @@ -1194,6 +1194,20 @@ def test_config_toml(
skip = 'bad.txt,whatever.txt'
check-filenames = false
count = true
"""
)
else:
assert kind == "toml_list"
if sys.version_info < (3, 11):
pytest.importorskip("tomli")
tomlfile = tmp_path / "pyproject.toml"
args = ("--toml", tomlfile)
tomlfile.write_text(
"""\
[tool.codespell]
skip = ['bad.txt', 'whatever.txt']
check-filenames = false
count = true
"""
)

Expand Down