Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused Python import statements #31

Closed
eoaksnes opened this issue Jun 22, 2022 · 0 comments · Fixed by #52, #59, #65, #66 or #67
Closed

Remove unused Python import statements #31

eoaksnes opened this issue Jun 22, 2022 · 0 comments · Fixed by #52, #59, #65, #66 or #67
Assignees

Comments

@eoaksnes
Copy link
Collaborator

eoaksnes commented Jun 22, 2022

Option 1:

autoflake removes unused imports and unused variables from Python code. It makes use of pyflakes to do this.

Example:

- repo: https://github.com/humitos/mirrors-autoflake.git
  rev: v1.1
  hooks:
    - id: autoflake
      args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variable']

Option 2:

pycln: a formatter for finding and removing unused import statements

Example:

-   repo: https://github.com/hadialqattan/pycln
    rev: v0.0.1-beta.3
    hooks:
    -   id: pycln
        args: [--config=pyproject.toml]

Maybe there exist other options also...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment