Skip to content

Commit

Permalink
Add autoflake to remove unused imports in cloud modules (#70)
Browse files Browse the repository at this point in the history
* Add autoflake to remove unused imports in cloud modules

* Add changelog

* Update roles/module_openapi_cloud/tasks/main.yaml

Co-authored-by: Mario Lenz <m@riolenz.de>

---------

Co-authored-by: Mario Lenz <m@riolenz.de>
  • Loading branch information
GomathiselviS and mariolenz authored Nov 8, 2023
1 parent 1e706b4 commit 1a8071e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Tested with ansible-core 2.13 releases and the current development version of an
## Installation

```
pip install black==22.3.0 jsonschema jinja2==3.0.3 ansible-core
pip install black==22.3.0 autoflake jsonschema jinja2==3.0.3 ansible-core
ansible-galaxy collection install git+https://github.com/ansible-community/ansible.content_builder.git
```

Expand Down
2 changes: 2 additions & 0 deletions changelogs/fragments/add_autoflake.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- "Adds a task to the module_openapi_cloud role to remove unused imports from the generated module."
2 changes: 1 addition & 1 deletion docs/rm_dev_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Once the above repo is cloned, go to the desired collection and add your model t
At first, we would need a builder for our whole code base to get scaffolded from a tool - `content_builder`

```
pip install black jsonschema jinja2==3.0.3 ansible-core
pip install black autoflake jsonschema jinja2==3.0.3 ansible-core
ansible-galaxy collection install git+https://github.com/ansible-community/ansible.content_builder.git
```

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ oyaml
boto3
baron
redbaron
autoflake
6 changes: 6 additions & 0 deletions roles/module_openapi_cloud/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
- ( plugin['action'] == 'generate_ignore_files' ) or ( plugin['action'] == 'generate_all' )
- plugin['name'] == 'vmware_rest'

- name: Use autoflake to remove unused imports
ansible.builtin.command: "autoflake --in-place --remove-all-unused-imports -r {{ collection['path'] }}"
delegate_to: 127.0.0.1
run_once: true
changed_when: false

- name: Format the files in the collection using black
ansible.builtin.command: "black {{ collection['path'] }}"
delegate_to: 127.0.0.1
Expand Down

0 comments on commit 1a8071e

Please sign in to comment.