Skip to content

Commit 6d0f1c4

Browse files
authored
Add support for passing the .toml config in the arguments (#285)
1 parent 1c061f3 commit 6d0f1c4

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

autoflake.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,11 @@ def merge_configuration_file(
12511251

12521252
if "config_file" in flag_args:
12531253
config_file = pathlib.Path(flag_args["config_file"]).resolve()
1254-
config = process_config_file(str(config_file))
1254+
process_method = process_config_file
1255+
if config_file.suffix == ".toml":
1256+
process_method = process_pyproject_toml
1257+
1258+
config = process_method(str(config_file))
12551259

12561260
if not config:
12571261
_LOGGER.error(

test_autoflake.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3389,6 +3389,28 @@ def test_config_option(self) -> None:
33893389
check=True,
33903390
)
33913391

3392+
def test_merge_configuration_file__toml_config_option(self) -> None:
3393+
with temporary_file(
3394+
suffix=".toml",
3395+
contents=("[tool.autoflake]\n" "check = true\n"),
3396+
) as temp_config:
3397+
self.create_file("test_me.py")
3398+
files = [self.effective_path("test_me.py")]
3399+
3400+
args, success = autoflake.merge_configuration_file(
3401+
{
3402+
"files": files,
3403+
"config_file": temp_config,
3404+
},
3405+
)
3406+
3407+
assert success is True
3408+
assert args == self.with_defaults(
3409+
files=files,
3410+
config_file=temp_config,
3411+
check=True,
3412+
)
3413+
33923414
def test_load_false(self) -> None:
33933415
self.create_file("test_me.py")
33943416
self.create_file(

0 commit comments

Comments
 (0)