mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-26 21:33:12 +00:00
CI: add type checking (#10997)
* Set up type checking with mypy. * Make mypy pass. * Use list() instead of sorted().
This commit is contained in:
@@ -10,8 +10,9 @@ from collections.abc import Mapping
|
||||
try:
|
||||
# Introduced with Data Tagging (https://github.com/ansible/ansible/pull/84621):
|
||||
from ansible.module_utils.datatag import native_type_name as _native_type_name
|
||||
HAS_NATIVE_TYPE_NAME = True
|
||||
except ImportError:
|
||||
_native_type_name = None
|
||||
HAS_NATIVE_TYPE_NAME = False
|
||||
|
||||
|
||||
def _atype(data, alias, *, use_native_type: bool = False):
|
||||
@@ -19,7 +20,7 @@ def _atype(data, alias, *, use_native_type: bool = False):
|
||||
Returns the name of the type class.
|
||||
"""
|
||||
|
||||
if use_native_type and _native_type_name:
|
||||
if use_native_type and HAS_NATIVE_TYPE_NAME:
|
||||
data_type = _native_type_name(data)
|
||||
else:
|
||||
data_type = type(data).__name__
|
||||
|
||||
Reference in New Issue
Block a user