From 74152807285a1e6e3ed74ae579b12e1ebcb824e9 Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman Date: Tue, 15 Dec 2020 18:40:45 -0300 Subject: [PATCH 1/4] [flake8-bugbear] Fix unused loop variable. Running flake8 with bugbear enable found an extra for-loop that is not needed. The for-loop was removed, fixing bubear's warning. --- plugins/modules/ipadnsrecord.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/modules/ipadnsrecord.py b/plugins/modules/ipadnsrecord.py index c3490480..4de8a949 100644 --- a/plugins/modules/ipadnsrecord.py +++ b/plugins/modules/ipadnsrecord.py @@ -1375,10 +1375,9 @@ def define_commands_for_present_state(module, zone_name, entry, res_find): # remove record from args, as it will not be used again. del args[record] else: - for f in part_fields: - _args = {k: args[k] for k in part_fields} - _args['idnsname'] = name - _commands.append([zone_name, 'dnsrecord_add', _args]) + _args = {k: args[k] for k in part_fields if k in args} + _args['idnsname'] = name + _commands.append([zone_name, 'dnsrecord_add', _args]) # clean used fields from args for f in part_fields: if f in args: From ba697466a3f0869bb0e6fac4d61f29ca2136c07b Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman Date: Tue, 15 Dec 2020 18:42:36 -0300 Subject: [PATCH 2/4] [flake8-bugbear] Fix unused loop variable. This commit change the name of a variable to make it more clear that it is not required in the for-loop, removing a bugbear B007 warning. --- tests/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/utils.py b/tests/utils.py index bd1bbf53..d681b0d6 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -169,7 +169,7 @@ def list_test_yaml(dir_path): `test_` and the extension is `.yml`. """ yamls = [] - for root, dirs, files in os.walk(dir_path): + for root, _dirs, files in os.walk(dir_path): for yaml_name in files: if yaml_name.startswith("test_") and yaml_name.endswith(".yml"): test_yaml_path = os.path.join(root, yaml_name) From f89330a80dbc4840997ceb253b143805aa6a19e2 Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman Date: Tue, 15 Dec 2020 18:46:23 -0300 Subject: [PATCH 3/4] Use Python Linter action with support for flake8's bugbear. --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index fc05dfe9..3ddc5bd6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -30,4 +30,4 @@ jobs: uses: ibiqlik/action-yamllint@v1 - name: Run Python linters - uses: rjeffman/python-lint-action@master + uses: rjeffman/python-lint-action@v2 From 97b06ff6f098df3a3a49625dea3619e9292e188d Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman Date: Tue, 15 Dec 2020 18:56:14 -0300 Subject: [PATCH 4/4] Update configuration to use flake8-bugbear. Bugbear is a plugin for Flake8 finding likely bugs and design problems. It contain warnings that don't belong in pyflakes and pycodestyle, and do not have a PEP or standard behind them. Ref: https://github.com/PyCQA/flake8-bugbear --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index 6b77754b..4384655f 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,4 @@ -r requirements-tests.txt ipdb pre-commit +flake8-bugbear