Skip to main content

pyproject-autoflake (pautoflake), a monkey patching wrapper to connect autoflake with pyproject.toml configuration.

Project description

pyproject-autoflake

PyPI version Python Versions

pyproject-autoflake (pautoflake), a monkey patching wrapper to connect autoflake with pyproject.toml configuration.

Motivation

The original autoflake does not support configuration files such as pyproject.toml. This is slightly inconvenient for modern Python development.

pautoflake is a thin wrapper library that calls autoflake with a configuration read from pyproject.toml.

pyproject-autoflake is inspired by pyproject-flake8. Many thanks! 😉

Installation

pip

pip install pyproject-autoflake

poetry

poetry add -D pyproject-autoflake

Usage

At first, you add [tool.autoflake] in your pyproject.toml.

# pyproject.toml

...

[tool.autoflake]
# return error code if changes are needed
check = false
# make changes to files instead of printing diffs
in-place = true
# drill down directories recursively
recursive = true
# exclude file/directory names that match these comma-separated globs
exclude = "<GLOBS>"
# by default, only unused standard library imports are removed; specify a comma-separated list of additional
# modules/packages
imports = "<IMPORTS>"
# expand wildcard star imports with undefined names; this only triggers if there is only one star import in
# the file; this is skipped if there are any uses of `__all__` or `del` in the file
expand-star-imports = true
# remove all unused imports (not just those from the standard library)
remove-all-unused-imports = true
# exclude __init__.py when removing unused imports
ignore-init-module-imports = true
# remove all duplicate keys in objects
remove-duplicate-keys = true
# remove unused variables
remove-unused-variables = true
# print more verbose logs (larger numbers are more verbose)
verbose = 0

...

Second, you call pautoflake.

pautoflake sample.py

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyproject-autoflake-1.0.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

pyproject_autoflake-1.0.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file pyproject-autoflake-1.0.2.tar.gz.

File metadata

  • Download URL: pyproject-autoflake-1.0.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.6.15 Linux/5.15.0-1014-azure

File hashes

Hashes for pyproject-autoflake-1.0.2.tar.gz
Algorithm Hash digest
SHA256 7ad1ab8c8e522bd04f05728f2656935853288b7b974a47850174c6cf6cc378ad
MD5 7dbd0b7d6292a680a99110829ca55ad7
BLAKE2b-256 89ce85563b11e0ee67bd2ab7f374e6dd5a53aca6a039e0b5449b7dfddd779a13

See more details on using hashes here.

File details

Details for the file pyproject_autoflake-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pyproject_autoflake-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 db7220bec762cbc8cfe93f1d23f3a564d0c076529bc1ebafc2dcb023c5ee265c
MD5 6ccbaaced598358e63597d1ceca64fb6
BLAKE2b-256 b8d67494a533baef27a6b43227ea5a264c249bd654e271f9c95920bd04805385

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page