-
-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Hello there!
I found a bug where the 'style' argument is ignored from the configuration file
This is my the section of my toml
[tool.pydocstringformatter]
style = "randomdoc"
exclude = [".tox/**"]
max-line-length = 88After a little lurking I think it is caused by this ....
The style arg is defined as an extend.
pydocstringformatter/pydocstringformatter/_configuration/arguments_manager.py
Lines 121 to 128 in 7a97321
| self.configuration_group.add_argument( | |
| "--style", | |
| action="extend", | |
| type=str, | |
| nargs="+", | |
| choices=["pep257", "numpydoc"], | |
| help="Docstring styles that are used in the project. Can be more than one.", | |
| ) |
And extend style args are not checked in the parsing of the toml file. Thus replacing whatever is in the field with
an empty list (which gets ignored later)
| if isinstance(action, argparse._StoreTrueAction): | |
| 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 |
Possible fix:
changing the pydocstringformatter/_configuration/toml_parsing.py#L44-L52 to ...
if isinstance(action, argparse._StoreTrueAction):
if value is True:
return [action.option_strings[0]]
return []
elif isinstance(action, argparse._StoreAction):
if isinstance(value, int):
value = str(value)
return [action.option_strings[0], value]
elif isinstance(action, argparse._ExtendAction):
if isinstance(value, str):
value = str(value)
return [action.option_strings[0], value]
else:
raise NotImplementedError
# return [] # pragma: no coverso it 1 Checks for the extend type args and 2 makes maintaining the package easier because it throws an error instead of silently ignored wrongly parsed files.
btw ... debugging was not super easy to be honest, is there a way to have the cli return the configuration that will be used? (explicit version of all the configuration arguments) ... like --verbose argument.
Let me know if you would like me to make PR for any of these
Best!
Sebastian