Skip to content

Commit

Permalink
Add support for passing the .toml config in the arguments (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
bp72 committed Nov 10, 2023
1 parent 1c061f3 commit 6d0f1c4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
6 changes: 5 additions & 1 deletion autoflake.py
Expand Up @@ -1251,7 +1251,11 @@ def merge_configuration_file(

if "config_file" in flag_args:
config_file = pathlib.Path(flag_args["config_file"]).resolve()
config = process_config_file(str(config_file))
process_method = process_config_file
if config_file.suffix == ".toml":
process_method = process_pyproject_toml

config = process_method(str(config_file))

if not config:
_LOGGER.error(
Expand Down
22 changes: 22 additions & 0 deletions test_autoflake.py
Expand Up @@ -3389,6 +3389,28 @@ def test_config_option(self) -> None:
check=True,
)

def test_merge_configuration_file__toml_config_option(self) -> None:
with temporary_file(
suffix=".toml",
contents=("[tool.autoflake]\n" "check = true\n"),
) as temp_config:
self.create_file("test_me.py")
files = [self.effective_path("test_me.py")]

args, success = autoflake.merge_configuration_file(
{
"files": files,
"config_file": temp_config,
},
)

assert success is True
assert args == self.with_defaults(
files=files,
config_file=temp_config,
check=True,
)

def test_load_false(self) -> None:
self.create_file("test_me.py")
self.create_file(
Expand Down

0 comments on commit 6d0f1c4

Please sign in to comment.