Skip to content

Commit

Permalink
Enable pylint codes C0411, E1101, R0205
Browse files Browse the repository at this point in the history
  • Loading branch information
Shrews committed Jul 13, 2023
1 parent 20cc855 commit 4273689
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 22 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ disable = [

enable = [
"C0209", # consider-using-f-string
"C0411", # wrong-import-order
"E1101", # no-member
"R0205", # useless-object-inheritance
"W0102", # dangerous-default-value
"W1202", # logging-format-interpolation
"W1203", # logging-fstring-interpolation
Expand Down
9 changes: 4 additions & 5 deletions src/ansible_runner/config/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@
import json
import logging
import os
import pexpect
import re
import stat
import tempfile
import shutil

from base64 import b64encode
from uuid import uuid4
from collections.abc import Mapping

import pexpect
from six import iteritems, string_types

from ansible_runner import defaults
Expand All @@ -48,15 +47,15 @@
logger = logging.getLogger('ansible-runner')


class BaseExecutionMode():
class BaseExecutionMode:
NONE = 0
# run ansible commands either locally or within EE
ANSIBLE_COMMANDS = 1
# execute generic commands
GENERIC_COMMANDS = 2


class BaseConfig(object):
class BaseConfig:

def __init__(self,
private_data_dir=None, host_cwd=None, envvars=None, passwords=None, settings=None,
Expand Down Expand Up @@ -462,7 +461,7 @@ def wrap_args_for_containerization(self, args, execution_mode, cmdline_args):
new_args = [self.process_isolation_executable]
new_args.extend(['run', '--rm'])

if self.runner_mode == 'pexpect' or hasattr(self, 'input_fd') and self.input_fd is not None:
if self.runner_mode == 'pexpect' or getattr(self, 'input_fd', False):
new_args.extend(['--tty'])

new_args.append('--interactive')
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_runner/config/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import shlex
import stat
import tempfile
import six
import shutil

import six
from six import string_types, text_type

from ansible_runner import output
Expand Down
4 changes: 2 additions & 2 deletions src/ansible_runner/display_callback/callback/awx_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def set(self, key, value):
os.rename(write_location, dropoff_location)


class EventContext(object):
class EventContext:

Check warning on line 121 in src/ansible_runner/display_callback/callback/awx_display.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_runner/display_callback/callback/awx_display.py#L121

Added line #L121 was not covered by tests
'''
Store global and local (per thread/process) data associated with callback
events and other display output methods.
Expand Down Expand Up @@ -417,7 +417,7 @@ def set_task(self, task, local=False):
task_ctx['task_path'] = task.get_path()
except AttributeError:
pass
if C.DISPLAY_ARGS_TO_STDOUT:
if C.DISPLAY_ARGS_TO_STDOUT: # pylint: disable=E1101
if task.no_log:
task_ctx['task_args'] = "the output has been hidden due to the fact that 'no_log: true' was specified for this result"
else:
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_runner/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from ansible_runner.output import debug


class ArtifactLoader(object):
class ArtifactLoader:
'''
Handles loading and caching file contents from disk
Expand Down
6 changes: 3 additions & 3 deletions src/ansible_runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
import collections
import datetime
import logging

import six
import pexpect

import ansible_runner.plugins
from ansible_runner.output import debug

from .utils import OutputEventFilter, cleanup_artifact_dir, ensure_str, collect_new_events
from .exceptions import CallbackError, AnsibleRunnerException
from ansible_runner.output import debug


logger = logging.getLogger('ansible-runner')


class Runner(object):
class Runner:

def __init__(self, config, cancel_callback=None, remove_partials=True, event_handler=None,
artifacts_handler=None, finished_callback=None, status_handler=None):
Expand Down
13 changes: 7 additions & 6 deletions src/ansible_runner/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
import uuid
import traceback

from collections.abc import Mapping
from functools import wraps
from threading import Event, RLock, Thread

import ansible_runner
from ansible_runner.exceptions import ConfigurationError
from ansible_runner.loader import ArtifactLoader
import ansible_runner.plugins
from ansible_runner.utils import register_for_cleanup
from ansible_runner.utils.streaming import stream_dir, unstream_dir
from collections.abc import Mapping
from functools import wraps
from threading import Event, RLock, Thread


class UUIDEncoder(json.JSONEncoder):
Expand All @@ -27,12 +28,12 @@ def default(self, obj):
return json.JSONEncoder.default(self, obj)


class MockConfig(object):
class MockConfig:
def __init__(self, settings):
self.settings = settings


class Transmitter(object):
class Transmitter:
def __init__(self, _output=None, **kwargs):
if _output is None:
_output = sys.stdout.buffer
Expand Down Expand Up @@ -239,7 +240,7 @@ def finished_callback(self, runner_obj):
self._output.flush()


class Processor(object):
class Processor:
def __init__(self, _input=None, status_handler=None, event_handler=None,
artifacts_handler=None, cancel_callback=None, finished_callback=None, **kwargs):
if _input is None:
Expand Down
8 changes: 4 additions & 4 deletions src/ansible_runner/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import atexit
import signal

from ansible_runner.exceptions import ConfigurationError

from collections.abc import Iterable, MutableMapping
from io import StringIO
from six import string_types, PY2, PY3, text_type, binary_type

from ansible_runner.exceptions import ConfigurationError


def cleanup_folder(folder):
"""Deletes folder, returns True or False based on whether a change happened."""
Expand Down Expand Up @@ -58,7 +58,7 @@ def is_dir_owner(directory):
return bool(current_user == callback_owner)


class Bunch(object):
class Bunch:

'''
Collect a bunch of variables together in an object.
Expand Down Expand Up @@ -276,7 +276,7 @@ def collect_new_events(event_path, old_events):
yield event, old_events


class OutputEventFilter(object):
class OutputEventFilter:
'''
File-like object that looks for encoded job events in stdout data.
'''
Expand Down

0 comments on commit 4273689

Please sign in to comment.