autoflake
autoflake copied to clipboard
Breaking change to configuration logic in v2.1.0
By changing the config file resolution for .toml files, this new minor version has broken configuration in cases where the --config
CLI argument is used.
In the new version's changes, in the merge_configuration_file
function on line 1199 autoflake now calls the process_pyproject_toml
function for .toml files instead the process_config_file
function. The result is that the tool will now try to get the "tool.autoflake" section section instead of the "autoflake" section. In other words, a configuration file that worked with v2.0.2 breaks on v2.1.0 (and vice versa).
As an aside, is there a place where release notes are posted? I couldn't find them on GH or Pypi.
Hi @kevinr-electric, thanks for reporting. I'm going to revert that change and then we can have a separate flag that's exclusive for the location of pyproject.toml.
Currently, autoflake doesn't keep a changelog in a dedicated location. We can introduce something with GitHub releases though.
Hey @fsouza, thanks for the update. A releases section with release notes would also be appreciated!
I'm confused here; Passing a toml file to --config
was completely broken before (that was the whole point of this PR). How were you doing that?
In version 2.1.1, I'm seeing that [autoflake] works, but [tool.autoflake] does not for a pyproject.toml file.
This is in direct contradiction to the PyPi docs
@joeyagreco can you share an example? I can't repro it:
% cat pyproject.toml
[project]
name = "sample"
description = "Just a sample"
license = { text = "ISC" }
[tool.autoflake]
expand-star-imports = true
% cat sample.py
import os
from sys import *
print("hi", file=stderr)
% autoflake sample.py
--- original/sample.py
+++ fixed/sample.py
@@ -1,4 +1,3 @@
-import os
-from sys import *
+from sys import stderr
print("hi", file=stderr)
% autoflake --version
autoflake 2.1.1
Sure! @fsouza
Here's my pyproject.toml
file
[autoflake]
ignore_init_module_imports = true
in_place = true
recursive = true
remove_all_unused_imports = true
Check version
% autoflake --version
> autoflake 2.1.1
Run it
% autoflake --config=pyproject.toml .
>
Works (removes an unused import)
Let's change the pyproject.toml
[tool.autoflake]
ignore_init_module_imports = true
in_place = true
recursive = true
remove_all_unused_imports = true
Now let's run it again
% autoflake --config=pyproject.toml .
> can't parse config file 'C:\foo\baz\pyproject.toml'
@joeyagreco ahh ok, yes --config
doesn't support pyproject.toml
at the moment. It's being parsed as an ini file, and toml just happens to be compatible with that.
I'm confused here; Passing a toml file to --config was completely broken before (that was the whole point of https://github.com/PyCQA/autoflake/pull/249). How were you doing that?
Sorry, I had missed this message, but I assume people were relying on the fact that simple toml files can be parsed as ini files. After thinking about this a little bit, I feel like we can roll #249 forward again. Alternatively, we could have a dedicated flag for pyproject.toml.