mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-31 15:53:09 +00:00
Use isinstance instead of type() comparisons. isinstance is more robust
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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__
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,4 +4,3 @@ E125
|
||||
E129
|
||||
E501
|
||||
E712
|
||||
E721
|
||||
|
||||
Reference in New Issue
Block a user