Fixed flake8 excludes and new-lines
- Adopt recommended way to call flake8 via pre-commit and fix excludes. - This allows calling flake8 as standalone too - Used black rules - Fixed several wrong newlines (fixed by pre-commit) Change-Id: I07be03c43928e0f5f44cd9a262841723193230c3
This commit is contained in:
@@ -10,13 +10,12 @@ repos:
|
||||
- id: check-executables-have-shebangs
|
||||
- id: check-merge-conflict
|
||||
- id: debug-statements
|
||||
- id: flake8
|
||||
entry: flake8 --ignore=E24,E121,E122,E123,E124,E126,E226,E265,E305,E402,F401,F405,E501,E704,F403,F841,W503
|
||||
# TODO(cloudnull): These codes were added to pass the lint check.
|
||||
# All of these ignore codes should be resolved in
|
||||
# future PRs.
|
||||
- id: check-yaml
|
||||
files: .*\.(yaml|yml)$
|
||||
- repo: https://gitlab.com/pycqa/flake8
|
||||
rev: '3.7.9'
|
||||
hooks:
|
||||
- id: flake8
|
||||
- repo: https://github.com/adrienverge/yamllint.git
|
||||
rev: v1.20.0
|
||||
hooks:
|
||||
|
||||
@@ -24,7 +24,6 @@ from ansible.module_utils.parsing.convert_bool import boolean
|
||||
from ansible.plugins.action import ActionBase
|
||||
from datetime import datetime
|
||||
|
||||
import json
|
||||
import yaml
|
||||
|
||||
ANSIBLE_METADATA = {
|
||||
@@ -102,7 +101,7 @@ class ActionModule(ActionBase):
|
||||
|
||||
if missing:
|
||||
raise AnsibleActionFail('Missing required parameters: {}'.format(
|
||||
', '.join(missing)))
|
||||
', '.join(missing)))
|
||||
return args
|
||||
|
||||
def _get_date_string(self, date_format):
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
localhost
|
||||
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
localhost
|
||||
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
localhost
|
||||
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
localhost
|
||||
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
localhost
|
||||
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
localhost
|
||||
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
localhost
|
||||
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
localhost
|
||||
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
localhost
|
||||
|
||||
|
||||
@@ -45,3 +45,8 @@ universal = 1
|
||||
[pbr]
|
||||
skip_authors = True
|
||||
skip_changelog = True
|
||||
|
||||
[flake8]
|
||||
# based on https://github.com/psf/black
|
||||
ignore = E203,E501,W503,W504,D
|
||||
# "D" added because we do not use docstrings checks, yet
|
||||
|
||||
@@ -54,17 +54,18 @@ class TestTimestampFile(tests_base.TestCase):
|
||||
|
||||
result = action.run()
|
||||
|
||||
execute_calls = [mock.call(module_args={'path': 'foo.log'},
|
||||
module_name='stat',
|
||||
task_vars={}),
|
||||
mock.call(module_args={'path': 'foo.log.foo'},
|
||||
module_name='stat',
|
||||
task_vars={}),
|
||||
mock.call(module_args={'src': 'foo.log',
|
||||
'dest': 'foo.log.foo',
|
||||
'remote_src': True},
|
||||
module_name='copy',
|
||||
task_vars={})
|
||||
execute_calls = [
|
||||
mock.call(module_args={'path': 'foo.log'},
|
||||
module_name='stat',
|
||||
task_vars={}),
|
||||
mock.call(module_args={'path': 'foo.log.foo'},
|
||||
module_name='stat',
|
||||
task_vars={}),
|
||||
mock.call(module_args={'src': 'foo.log',
|
||||
'dest': 'foo.log.foo',
|
||||
'remote_src': True},
|
||||
module_name='copy',
|
||||
task_vars={})
|
||||
]
|
||||
self.assertEqual(3, mock_execute.call_count)
|
||||
mock_execute.assert_has_calls(execute_calls)
|
||||
@@ -95,11 +96,12 @@ class TestTimestampFile(tests_base.TestCase):
|
||||
|
||||
action._execute_module = mock_execute
|
||||
|
||||
self.assertRaises(AnsibleActionSkip, action.run)
|
||||
self.assertRaises(AnsibleActionSkip, action.run)
|
||||
|
||||
execute_calls = [mock.call(module_args={'path': 'foo.log'},
|
||||
module_name='stat',
|
||||
task_vars={})
|
||||
execute_calls = [
|
||||
mock.call(module_args={'path': 'foo.log'},
|
||||
module_name='stat',
|
||||
task_vars={})
|
||||
]
|
||||
self.assertEqual(1, mock_execute.call_count)
|
||||
mock_execute.assert_has_calls(execute_calls)
|
||||
@@ -128,14 +130,15 @@ class TestTimestampFile(tests_base.TestCase):
|
||||
|
||||
action._execute_module = mock_execute
|
||||
|
||||
self.assertRaises(AnsibleActionFail, action.run)
|
||||
self.assertRaises(AnsibleActionFail, action.run)
|
||||
|
||||
execute_calls = [mock.call(module_args={'path': 'foo.log'},
|
||||
module_name='stat',
|
||||
task_vars={}),
|
||||
mock.call(module_args={'path': 'foo.log.foo'},
|
||||
module_name='stat',
|
||||
task_vars={})
|
||||
execute_calls = [
|
||||
mock.call(module_args={'path': 'foo.log'},
|
||||
module_name='stat',
|
||||
task_vars={}),
|
||||
mock.call(module_args={'path': 'foo.log.foo'},
|
||||
module_name='stat',
|
||||
task_vars={})
|
||||
]
|
||||
self.assertEqual(2, mock_execute.call_count)
|
||||
mock_execute.assert_has_calls(execute_calls)
|
||||
@@ -169,17 +172,18 @@ class TestTimestampFile(tests_base.TestCase):
|
||||
|
||||
result = action.run()
|
||||
|
||||
execute_calls = [mock.call(module_args={'path': 'foo.log'},
|
||||
module_name='stat',
|
||||
task_vars={}),
|
||||
mock.call(module_args={'path': 'foo.log.foo'},
|
||||
module_name='stat',
|
||||
task_vars={}),
|
||||
mock.call(module_args={'src': 'foo.log',
|
||||
'dest': 'foo.log.foo',
|
||||
'remote_src': True},
|
||||
module_name='copy',
|
||||
task_vars={})
|
||||
execute_calls = [
|
||||
mock.call(module_args={'path': 'foo.log'},
|
||||
module_name='stat',
|
||||
task_vars={}),
|
||||
mock.call(module_args={'path': 'foo.log.foo'},
|
||||
module_name='stat',
|
||||
task_vars={}),
|
||||
mock.call(module_args={'src': 'foo.log',
|
||||
'dest': 'foo.log.foo',
|
||||
'remote_src': True},
|
||||
module_name='copy',
|
||||
task_vars={})
|
||||
]
|
||||
self.assertEqual(3, mock_execute.call_count)
|
||||
mock_execute.assert_has_calls(execute_calls)
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
|
||||
from tests import base as tests_base
|
||||
from plugins.filter import shell_args
|
||||
|
||||
|
||||
Reference in New Issue
Block a user