Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
7 changes: 6 additions & 1 deletion pydocstringformatter/_configuration/toml_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ def parse_toml_option(
if value is True:
return [action.option_strings[0]]
return []

if isinstance(action, argparse._StoreAction):
if isinstance(value, int):
value = str(value)
return [action.option_strings[0], value]
return [] # pragma: no cover

if isinstance(action, argparse._ExtendAction): # type: ignore[attr-defined]
return [action.option_strings[0], value]

raise NotImplementedError # pragma: no cover


def parse_toml_file(
Expand Down
3 changes: 3 additions & 0 deletions tests/data/config/valid_toml_numpydoc/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tool.pydocstringformatter]
write = false
style = 'numpydoc'
3 changes: 3 additions & 0 deletions tests/data/config/valid_toml_pep257/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tool.pydocstringformatter]
write = false
style = 'pep257'
10 changes: 10 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,13 @@ def test_style_invalid_choice(self, capsys: pytest.CaptureFixture[str]) -> None:
output = capsys.readouterr()
assert not output.out
assert "--style: invalid choice: 'invalid'" in output.err

def test_style_in_toml(self, monkeypatch: pytest.MonkeyPatch) -> None:
"""Test that the style argument works in the toml file."""
monkeypatch.chdir(CONFIG_DATA / "valid_toml_numpydoc")
run = _Run(["test_package"])
assert ["numpydoc"] == run.config.style

monkeypatch.chdir(CONFIG_DATA / "valid_toml_pep257")
run = _Run(["test_package"])
assert ["pep257"] == run.config.style