mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 22:51:23 -07:00
replace type() with isinstance() (#5541)
Replace all use of type() with isintance() Addresses https://github.com/ansible/ansible/issues/18310
This commit is contained in:
parent
2744fde7c9
commit
06e1141106
7 changed files with 17 additions and 17 deletions
|
@ -388,7 +388,7 @@ def _exit_hostvars(module, cloud, server, changed=True):
|
|||
|
||||
def _parse_nics(nics):
|
||||
for net in nics:
|
||||
if type(net) == str:
|
||||
if isinstance(net, str):
|
||||
for nic in net.split(','):
|
||||
yield dict((nic.split('='),))
|
||||
else:
|
||||
|
@ -398,11 +398,11 @@ def _network_args(module, cloud):
|
|||
args = []
|
||||
nics = module.params['nics']
|
||||
|
||||
if type(nics) != list:
|
||||
if not isinstance(nics, list):
|
||||
module.fail_json(msg='The \'nics\' parameter must be a list.')
|
||||
|
||||
for net in _parse_nics(nics):
|
||||
if type(net) != dict:
|
||||
if not isinstance(net, dict):
|
||||
module.fail_json(
|
||||
msg='Each entry in the \'nics\' parameter must be a dict.')
|
||||
|
||||
|
@ -459,7 +459,7 @@ def _create_server(module, cloud):
|
|||
|
||||
nics = _network_args(module, cloud)
|
||||
|
||||
if type(module.params['meta']) is str:
|
||||
if isinstance(module.params['meta'], str):
|
||||
metas = {}
|
||||
for kv_str in module.params['meta'].split(","):
|
||||
k, v = kv_str.split("=")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue