summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <a.badger@gmail.com>2017-02-16 15:47:09 -0800
committerToshio Kuratomi <a.badger@gmail.com>2017-02-16 16:34:43 -0800
commiteeaec56ed5bebb3366cc7aa80f63c3bf75436e8a (patch)
treef9b1402a9b6ab09e3a4dd9b97bcb3f1c42110067
parent2192c1eb02ecde6a07928f284e819ba9af3a8327 (diff)
downloadansible-eeaec56ed5bebb3366cc7aa80f63c3bf75436e8a.tar.gz
Use isinstance instead of type() comparisons. isinstance is more robust
-rw-r--r--lib/ansible/executor/stats.py6
-rw-r--r--lib/ansible/plugins/strategy/debug.py2
-rw-r--r--test/sanity/pep8/legacy-files.txt2
-rw-r--r--test/sanity/pep8/legacy-ignore.txt1
4 files changed, 5 insertions, 6 deletions
diff --git a/lib/ansible/executor/stats.py b/lib/ansible/executor/stats.py
index f91874d17a..482a147afb 100644
--- a/lib/ansible/executor/stats.py
+++ b/lib/ansible/executor/stats.py
@@ -19,6 +19,8 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
+from collections import MutableMapping
+
from ansible.utils.vars import merge_hash
class AggregateStats:
@@ -73,10 +75,10 @@ class AggregateStats:
return self.set_custom_stats(which, what, host)
# mismatching types
- if type(what) != type(self.custom[host][which]):
+ if not isinstance(what, type(self.custom[host][which])):
return None
- if isinstance(what, dict):
+ if isinstance(what, MutableMapping):
self.custom[host][which] = merge_hash(self.custom[host][which], what)
else:
# let overloaded + take care of other types
diff --git a/lib/ansible/plugins/strategy/debug.py b/lib/ansible/plugins/strategy/debug.py
index 61159d5fab..a9159dc1b7 100644
--- a/lib/ansible/plugins/strategy/debug.py
+++ b/lib/ansible/plugins/strategy/debug.py
@@ -144,7 +144,7 @@ class Debugger(cmd.Cmd):
exec(code, globals(), self.scope)
except:
t, v = sys.exc_info()[:2]
- if type(t) == type(''):
+ if isinstance(t, str):
exc_type_name = t
else:
exc_type_name = t.__name__
diff --git a/test/sanity/pep8/legacy-files.txt b/test/sanity/pep8/legacy-files.txt
index 5e82029b53..01e6e4d2a5 100644
--- a/test/sanity/pep8/legacy-files.txt
+++ b/test/sanity/pep8/legacy-files.txt
@@ -5,7 +5,6 @@ lib/ansible/compat/six/__init__.py
lib/ansible/constants.py
lib/ansible/errors/__init__.py
lib/ansible/executor/play_iterator.py
-lib/ansible/executor/stats.py
lib/ansible/executor/task_executor.py
lib/ansible/galaxy/role.py
lib/ansible/inventory/dir.py
@@ -260,7 +259,6 @@ lib/ansible/plugins/lookup/first_found.py
lib/ansible/plugins/shell/fish.py
lib/ansible/plugins/shell/sh.py
lib/ansible/plugins/strategy/__init__.py
-lib/ansible/plugins/strategy/debug.py
lib/ansible/plugins/strategy/linear.py
lib/ansible/template/__init__.py
lib/ansible/utils/encrypt.py
diff --git a/test/sanity/pep8/legacy-ignore.txt b/test/sanity/pep8/legacy-ignore.txt
index 14d09ab1ec..9e7f635246 100644
--- a/test/sanity/pep8/legacy-ignore.txt
+++ b/test/sanity/pep8/legacy-ignore.txt
@@ -4,4 +4,3 @@ E125
E129
E501
E712
-E721