Fix lints found by flake8
This commit is contained in:
parent
18c89de5a9
commit
109feec6d5
|
@ -1095,7 +1095,7 @@ class Connection(ansible.plugins.connection.ConnectionBase):
|
|||
s = fp.read(self.SMALL_FILE_LIMIT + 1)
|
||||
finally:
|
||||
fp.close()
|
||||
except OSError:
|
||||
except OSError as e:
|
||||
self._throw_io_error(e, in_path)
|
||||
raise
|
||||
|
||||
|
|
|
@ -297,11 +297,11 @@ class NewStylePlanner(ScriptPlanner):
|
|||
preprocessing the module.
|
||||
"""
|
||||
runner_name = 'NewStyleRunner'
|
||||
MARKER = re.compile(b'from ansible(?:_collections|\.module_utils)\.')
|
||||
MARKER = re.compile(br'from ansible(?:_collections|\.module_utils)\.')
|
||||
|
||||
@classmethod
|
||||
def detect(cls, path, source):
|
||||
return cls.MARKER.search(source) != None
|
||||
return cls.MARKER.search(source) is not None
|
||||
|
||||
def _get_interpreter(self):
|
||||
return None, None
|
||||
|
@ -522,12 +522,15 @@ def _invoke_isolated_task(invocation, planner):
|
|||
context.shutdown()
|
||||
|
||||
|
||||
def _get_planner(name, path, source):
|
||||
def _get_planner(invocation, source):
|
||||
for klass in _planners:
|
||||
if klass.detect(path, source):
|
||||
LOG.debug('%r accepted %r (filename %r)', klass, name, path)
|
||||
if klass.detect(invocation.module_path, source):
|
||||
LOG.debug(
|
||||
'%r accepted %r (filename %r)',
|
||||
klass, invocation.module_name, invocation.module_path,
|
||||
)
|
||||
return klass
|
||||
LOG.debug('%r rejected %r', klass, name)
|
||||
LOG.debug('%r rejected %r', klass, invocation.module_name)
|
||||
raise ansible.errors.AnsibleError(NO_METHOD_MSG + repr(invocation))
|
||||
|
||||
|
||||
|
@ -590,8 +593,7 @@ def invoke(invocation):
|
|||
module_source = invocation.get_module_source()
|
||||
_fix_py35(invocation, module_source)
|
||||
_planner_by_path[invocation.module_path] = _get_planner(
|
||||
invocation.module_name,
|
||||
invocation.module_path,
|
||||
invocation,
|
||||
module_source
|
||||
)
|
||||
|
||||
|
|
|
@ -2717,7 +2717,7 @@ class Latch(object):
|
|||
raise e
|
||||
|
||||
assert cookie == got_cookie, (
|
||||
"Cookie incorrect; got %r, expected %r" \
|
||||
"Cookie incorrect; got %r, expected %r"
|
||||
% (binascii.hexlify(got_cookie),
|
||||
binascii.hexlify(cookie))
|
||||
)
|
||||
|
@ -3672,7 +3672,6 @@ class Dispatcher(object):
|
|||
self._service_recv.notify = None
|
||||
self.recv.close()
|
||||
|
||||
|
||||
@classmethod
|
||||
@takes_econtext
|
||||
def forget_chain(cls, chain_id, econtext):
|
||||
|
|
|
@ -199,7 +199,7 @@ class Process(object):
|
|||
|
||||
def _on_stdin(self, msg):
|
||||
if msg.is_dead:
|
||||
IOLOG.debug('%r._on_stdin() -> %r', self, data)
|
||||
IOLOG.debug('%r._on_stdin() -> %r', self, msg)
|
||||
self.pump.protocol.close()
|
||||
return
|
||||
|
||||
|
@ -436,7 +436,7 @@ def run(dest, router, args, deadline=None, econtext=None):
|
|||
fp.write(inspect.getsource(mitogen.core))
|
||||
fp.write('\n')
|
||||
fp.write('ExternalContext(%r).main()\n' % (
|
||||
_get_econtext_config(context, sock2),
|
||||
_get_econtext_config(econtext, sock2),
|
||||
))
|
||||
finally:
|
||||
fp.close()
|
||||
|
|
|
@ -1508,7 +1508,7 @@ class Connection(object):
|
|||
|
||||
def get_preamble(self):
|
||||
suffix = (
|
||||
'\nExternalContext(%r).main()\n' %\
|
||||
'\nExternalContext(%r).main()\n' %
|
||||
(self.get_econtext_config(),)
|
||||
)
|
||||
partial = get_core_source_partial()
|
||||
|
|
Loading…
Reference in New Issue