diff --git a/hacking/return_skeleton_generator.py b/hacking/return_skeleton_generator.py index 83fd76a8920..7002b7899d5 100755 --- a/hacking/return_skeleton_generator.py +++ b/hacking/return_skeleton_generator.py @@ -90,7 +90,7 @@ def main(args): data = json.load(src, strict=False) docs = get_all_items(data) if 'invocation' in docs: - del(docs['invocation']) + del docs['invocation'] print(yaml.safe_dump(docs, default_flow_style=False)) diff --git a/lib/ansible/cli/__init__.py b/lib/ansible/cli/__init__.py index da62cfe2837..15ab5fe17ea 100644 --- a/lib/ansible/cli/__init__.py +++ b/lib/ansible/cli/__init__.py @@ -455,8 +455,8 @@ class CLI(ABC): try: options = self.parser.parse_args(self.args[1:]) - except SystemExit as e: - if(e.code != 0): + except SystemExit as ex: + if ex.code != 0: self.parser.exit(status=2, message=" \n%s" % self.parser.format_help()) raise options = self.post_process_args(options) diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index fb55dae772c..8cdf51bb5c0 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -1069,7 +1069,7 @@ class TaskExecutor: task_keys['password'] = self._play_context.password # Prevent task retries from overriding connection retries - del(task_keys['retries']) + del task_keys['retries'] # set options with 'templated vars' specific to this plugin and dependent ones self._connection.set_options(task_keys=task_keys, var_options=options) diff --git a/lib/ansible/modules/copy.py b/lib/ansible/modules/copy.py index ca6ae0df0eb..7fed4a5c8f1 100644 --- a/lib/ansible/modules/copy.py +++ b/lib/ansible/modules/copy.py @@ -469,7 +469,7 @@ def copy_left_only(src, dest, module): b_dest_item_path = to_bytes(dest_item_path, errors='surrogate_or_strict') if os.path.islink(b_src_item_path) and os.path.isdir(b_src_item_path) and local_follow is True: - shutil.copytree(b_src_item_path, b_dest_item_path, symlinks=not(local_follow)) + shutil.copytree(b_src_item_path, b_dest_item_path, symlinks=not local_follow) chown_recursive(b_dest_item_path, module) if os.path.islink(b_src_item_path) and os.path.isdir(b_src_item_path) and local_follow is False: @@ -497,7 +497,7 @@ def copy_left_only(src, dest, module): module.set_group_if_different(b_dest_item_path, group, False) if not os.path.islink(b_src_item_path) and os.path.isdir(b_src_item_path): - shutil.copytree(b_src_item_path, b_dest_item_path, symlinks=not(local_follow)) + shutil.copytree(b_src_item_path, b_dest_item_path, symlinks=not local_follow) chown_recursive(b_dest_item_path, module) changed = True @@ -766,7 +766,7 @@ def main(): b_dest = to_bytes(os.path.join(b_dest, b_basename), errors='surrogate_or_strict') b_src = to_bytes(os.path.join(module.params['src'], ""), errors='surrogate_or_strict') if not module.check_mode: - shutil.copytree(b_src, b_dest, symlinks=not(local_follow)) + shutil.copytree(b_src, b_dest, symlinks=not local_follow) chown_recursive(dest, module) changed = True @@ -775,7 +775,7 @@ def main(): b_dest = to_bytes(os.path.join(b_dest, b_basename), errors='surrogate_or_strict') b_src = to_bytes(os.path.join(module.params['src'], ""), errors='surrogate_or_strict') if not module.check_mode and not os.path.exists(b_dest): - shutil.copytree(b_src, b_dest, symlinks=not(local_follow)) + shutil.copytree(b_src, b_dest, symlinks=not local_follow) changed = True chown_recursive(dest, module) if module.check_mode and not os.path.exists(b_dest): diff --git a/lib/ansible/modules/find.py b/lib/ansible/modules/find.py index eb9c8aa8390..788eb71ded9 100644 --- a/lib/ansible/modules/find.py +++ b/lib/ansible/modules/find.py @@ -468,7 +468,7 @@ def main(): depth = int(fsname.count(os.path.sep)) - int(wpath.count(os.path.sep)) + 1 if depth > params['depth']: # Empty the list used by os.walk to avoid traversing deeper unnecessarily - del(dirs[:]) + del dirs[:] continue if os.path.basename(fsname).startswith('.') and not params['hidden']: continue diff --git a/lib/ansible/parsing/splitter.py b/lib/ansible/parsing/splitter.py index ab7df04db7b..b68444fef75 100644 --- a/lib/ansible/parsing/splitter.py +++ b/lib/ansible/parsing/splitter.py @@ -229,7 +229,7 @@ def split_args(args): # to the end of the list, since we'll tack on more to it later # otherwise, if we're inside any jinja2 block, inside quotes, or we were # inside quotes (but aren't now) concat this token to the last param - if inside_quotes and not was_inside_quotes and not(print_depth or block_depth or comment_depth): + if inside_quotes and not was_inside_quotes and not (print_depth or block_depth or comment_depth): params.append(token) appended = True elif print_depth or block_depth or comment_depth or inside_quotes or was_inside_quotes: diff --git a/lib/ansible/plugins/action/pause.py b/lib/ansible/plugins/action/pause.py index 5b6f9016f6f..4c98cbbff51 100644 --- a/lib/ansible/plugins/action/pause.py +++ b/lib/ansible/plugins/action/pause.py @@ -286,7 +286,7 @@ class ActionModule(ActionBase): finally: # cleanup and save some information # restore the old settings for the duped stdin stdin_fd - if not(None in (stdin_fd, old_settings)) and isatty(stdin_fd): + if not (None in (stdin_fd, old_settings)) and isatty(stdin_fd): termios.tcsetattr(stdin_fd, termios.TCSADRAIN, old_settings) duration = time.time() - start diff --git a/test/integration/targets/ansible/callback_plugins/callback_debug.py b/test/integration/targets/ansible/callback_plugins/callback_debug.py index cac122c1027..2462c1ff3fc 100644 --- a/test/integration/targets/ansible/callback_plugins/callback_debug.py +++ b/test/integration/targets/ansible/callback_plugins/callback_debug.py @@ -21,4 +21,4 @@ class CallbackModule(CallbackBase): def __getattr__(self, name): if name.startswith('v2_'): - return(lambda *args, **kwargs: self._display.display(name)) + return lambda *args, **kwargs: self._display.display(name) diff --git a/test/integration/targets/throttle/test_throttle.py b/test/integration/targets/throttle/test_throttle.py index 3ee8424eb75..1a5bdd30789 100755 --- a/test/integration/targets/throttle/test_throttle.py +++ b/test/integration/targets/throttle/test_throttle.py @@ -15,7 +15,7 @@ throttledir = os.path.expanduser(throttledir) throttlefile = os.path.join(throttledir, inventory_hostname) try: # create the file - with(open(throttlefile, 'a')): + with open(throttlefile, 'a'): os.utime(throttlefile, None) # count the number of files in the dir throttlelist = os.listdir(throttledir) diff --git a/test/lib/ansible_test/_internal/provider/layout/collection.py b/test/lib/ansible_test/_internal/provider/layout/collection.py index 1ee12b53992..299d0bc6df0 100644 --- a/test/lib/ansible_test/_internal/provider/layout/collection.py +++ b/test/lib/ansible_test/_internal/provider/layout/collection.py @@ -72,7 +72,7 @@ class CollectionLayout(LayoutProvider): unit_module_path='tests/unit/plugins/modules', unit_module_utils_path='tests/unit/plugins/module_utils', unit_messages=unit_messages, - unsupported=not(is_valid_identifier(collection_namespace) and is_valid_identifier(collection_name)), + unsupported=not (is_valid_identifier(collection_namespace) and is_valid_identifier(collection_name)), ) @staticmethod