This GitHub action automatically removes unused imports and variables from your Python code using autoflake.
The following parameters can be used in your custom action configuration.
Parameter | Required | Default | Description |
---|---|---|---|
commit_message | ❌ | 'Removed unused imports and variables' | Custom git commit message |
commit_options | ❌ | - | Custom git commit options |
file_pattern | ❌ | '*' | Custom file pattern for git add |
checkpath | ❌ | '.' | The path autoflake checks |
no_commit | ❌ | False | Avoid committing, if used in a pipeline |
options | ❌ | ' ' | Parameters to use with autoflake |
dry | ❌ | false | Dry-run the action to fail when detecting uncompliant files, instead of automatically fixing them. |
github_token | ❌ | ${{ github.token }} |
The default GITHUB_TOKEN or a Personal Access Token |
Note: using the same_commit option may lead to problems if other actions are relying on the commit being the same before and after the prettier action has ran. Keep this in mind.
This is a simple usage example of this script:
name: autoflake format
on:
pull_request:
push:
branches:
- master
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: creyD/autoflake_action@v1.1
with:
options: --in-place --remove-all-unused-imports -r
More documentation for writing a workflow can be found here.
Please report all bugs and feature request using the GitHub issues function.
To be able to push to your repository you will need to enable "Read and write permissions" for your repository. You can find these settings in the settings of the repository under Actions > General > Workflow Permissions.
If you do not set this, you might encounter this issue: