mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
Use isinstance instead of type() comparisons. isinstance is more robust
This commit is contained in:
parent
2192c1eb02
commit
eeaec56ed5
4 changed files with 5 additions and 6 deletions
|
@ -19,6 +19,8 @@
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
from collections import MutableMapping
|
||||||
|
|
||||||
from ansible.utils.vars import merge_hash
|
from ansible.utils.vars import merge_hash
|
||||||
|
|
||||||
class AggregateStats:
|
class AggregateStats:
|
||||||
|
@ -73,10 +75,10 @@ class AggregateStats:
|
||||||
return self.set_custom_stats(which, what, host)
|
return self.set_custom_stats(which, what, host)
|
||||||
|
|
||||||
# mismatching types
|
# mismatching types
|
||||||
if type(what) != type(self.custom[host][which]):
|
if not isinstance(what, type(self.custom[host][which])):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if isinstance(what, dict):
|
if isinstance(what, MutableMapping):
|
||||||
self.custom[host][which] = merge_hash(self.custom[host][which], what)
|
self.custom[host][which] = merge_hash(self.custom[host][which], what)
|
||||||
else:
|
else:
|
||||||
# let overloaded + take care of other types
|
# let overloaded + take care of other types
|
||||||
|
|
|
@ -144,7 +144,7 @@ class Debugger(cmd.Cmd):
|
||||||
exec(code, globals(), self.scope)
|
exec(code, globals(), self.scope)
|
||||||
except:
|
except:
|
||||||
t, v = sys.exc_info()[:2]
|
t, v = sys.exc_info()[:2]
|
||||||
if type(t) == type(''):
|
if isinstance(t, str):
|
||||||
exc_type_name = t
|
exc_type_name = t
|
||||||
else:
|
else:
|
||||||
exc_type_name = t.__name__
|
exc_type_name = t.__name__
|
||||||
|
|
|
@ -5,7 +5,6 @@ lib/ansible/compat/six/__init__.py
|
||||||
lib/ansible/constants.py
|
lib/ansible/constants.py
|
||||||
lib/ansible/errors/__init__.py
|
lib/ansible/errors/__init__.py
|
||||||
lib/ansible/executor/play_iterator.py
|
lib/ansible/executor/play_iterator.py
|
||||||
lib/ansible/executor/stats.py
|
|
||||||
lib/ansible/executor/task_executor.py
|
lib/ansible/executor/task_executor.py
|
||||||
lib/ansible/galaxy/role.py
|
lib/ansible/galaxy/role.py
|
||||||
lib/ansible/inventory/dir.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/fish.py
|
||||||
lib/ansible/plugins/shell/sh.py
|
lib/ansible/plugins/shell/sh.py
|
||||||
lib/ansible/plugins/strategy/__init__.py
|
lib/ansible/plugins/strategy/__init__.py
|
||||||
lib/ansible/plugins/strategy/debug.py
|
|
||||||
lib/ansible/plugins/strategy/linear.py
|
lib/ansible/plugins/strategy/linear.py
|
||||||
lib/ansible/template/__init__.py
|
lib/ansible/template/__init__.py
|
||||||
lib/ansible/utils/encrypt.py
|
lib/ansible/utils/encrypt.py
|
||||||
|
|
|
@ -4,4 +4,3 @@ E125
|
||||||
E129
|
E129
|
||||||
E501
|
E501
|
||||||
E712
|
E712
|
||||||
E721
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue