Skip to content

Commit

Permalink
fix: resolve configuration file precedence
Browse files Browse the repository at this point in the history
  • Loading branch information
paduszyk committed Jul 10, 2023
1 parent 5c9744e commit 9e208ff
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/docformatter/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,18 @@ def __init__(self, args: List[Union[bool, int, str]]) -> None:
self.config_file = self.args_lst[self.args_lst.index("--config") + 1]
except ValueError:
for _configuration_file in self.configuration_file_lst:
if os.path.isfile(_configuration_file):
self.config_file = f"./{_configuration_file}"
break
_config_section: str = (
"[tool.docformatter]"
if _configuration_file == "pyproject.toml"
else "[docformatter]"
)
_config_file_path: str = f"./{_configuration_file}"
if os.path.isfile(_config_file_path):
with open(_config_file_path, "r") as _config_file:
_config = _config_file.read()
if _config_section in _config:
self.config_file = _config_file_path
break

if os.path.isfile(self.config_file):
self._do_read_configuration_file()
Expand Down

0 comments on commit 9e208ff

Please sign in to comment.