mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-24 21:14:00 -07:00
use f-strings (#10899)
* use f-strings * add changelog frag * Apply suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
8a1ed41fe5
commit
3734f471c1
14 changed files with 50 additions and 54 deletions
|
|
@ -48,13 +48,13 @@ def _ansible_type(data, alias, *, use_native_type: bool = False):
|
|||
if data_type == 'list' and len(data) > 0:
|
||||
items = [_atype(i, alias, use_native_type=use_native_type) for i in data]
|
||||
items_type = '|'.join(sorted(set(items)))
|
||||
return ''.join((data_type, '[', items_type, ']'))
|
||||
return f"{data_type}[{items_type}]"
|
||||
|
||||
if data_type == 'dict' and len(data) > 0:
|
||||
keys = [_atype(i, alias, use_native_type=use_native_type) for i in data.keys()]
|
||||
vals = [_atype(i, alias, use_native_type=use_native_type) for i in data.values()]
|
||||
keys_type = '|'.join(sorted(set(keys)))
|
||||
vals_type = '|'.join(sorted(set(vals)))
|
||||
return ''.join((data_type, '[', keys_type, ', ', vals_type, ']'))
|
||||
return f"{data_type}[{keys_type}, {vals_type}]"
|
||||
|
||||
return data_type
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue