Comments (8)
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
from autoflake.
@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.
from autoflake.
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.
from autoflake.
Hey @fsouza, thanks for the update. A releases section with release notes would also be appreciated!
from autoflake.
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?
from autoflake.
@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
from autoflake.
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'
from autoflake.
I'm confused here; Passing a toml file to --config was completely broken before (that was the whole point of #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.
from autoflake.
Related Issues (20)
- [Feature request] Ignore import-only files
- Autoflake is removing imports specified in typehint comment HOT 1
- Removing import resorts imports in a way incompatible with isort HOT 3
- Run on jupyter notebook, with .ipynb extension
- Feature request: remove type-checking block instead of inserting pass
- Feature request: remove ellipsis
- (🎁) specify files in config file HOT 1
- Don't remove re-exported imports HOT 2
- Crash on specific pattern HOT 1
- MultiProcessing issue HOT 2
- Why remove-all-unused-imports isn't default behavior? HOT 1
- Mark https://pypi.org/project/autoflake8/ as deprecated too? HOT 1
- Avoid copying `py.typed` into site-packages? HOT 1
- Pre-commit hook with --remove-all-unused-imports always passes HOT 2
- Unused submodule imports are left if the top level module is used
- Cannot pass pyproject.toml to --config argument
- UnicodeDecodeError when running pre-commit on Windows with `v2.3.0` HOT 1
- autoflake removing imports that are used inside eval() function HOT 1
- Support exclusion of specific imports HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autoflake.