diff --git a/library/pcs_api_v2.py b/library/pcs_api_v2.py index 9ef79efb..c040743f 100644 --- a/library/pcs_api_v2.py +++ b/library/pcs_api_v2.py @@ -117,6 +117,7 @@ """ import traceback +from typing import Optional from ansible.module_utils.basic import AnsibleModule @@ -128,13 +129,18 @@ from pcs.common.async_tasks.dto import CommandDto, CommandOptionsDto except ImportError: HAS_PCS = False - PCS_IMPORT_ERROR = traceback.format_exc() + PCS_IMPORT_ERROR: Optional[str] = traceback.format_exc() - class CommandOptionsDto(object): - def __init__(self, **kwargs): + # These classes need to be available and imported above to do linting + # properly, linters can be safely silenced for these stubs. + + # pylint: disable=missing-class-docstring + # pylint: disable=too-few-public-methods + class CommandOptionsDto: # type: ignore + def __init__(self, **kwargs): # type: ignore pass - class CommandDto(object): + class CommandDto: # type: ignore pass else: diff --git a/library/pcs_qdevice_certs.py b/library/pcs_qdevice_certs.py index 8319ec6b..b9d44f8c 100644 --- a/library/pcs_qdevice_certs.py +++ b/library/pcs_qdevice_certs.py @@ -109,6 +109,7 @@ """ import traceback +from typing import Optional from ansible.module_utils.basic import AnsibleModule @@ -120,13 +121,18 @@ from pcs.common.async_tasks.dto import CommandDto, CommandOptionsDto except ImportError: HAS_PCS = False - PCS_IMPORT_ERROR = traceback.format_exc() + PCS_IMPORT_ERROR: Optional[str] = traceback.format_exc() - class CommandOptionsDto(object): - def __init__(self, **kwargs): + # These classes need to be available and imported above to do linting + # properly, linters can be safely silenced for these stubs. + + # pylint: disable=missing-class-docstring + # pylint: disable=too-few-public-methods + class CommandOptionsDto: # type: ignore + def __init__(self, **kwargs): # type: ignore pass - class CommandDto(object): + class CommandDto: # type: ignore pass else: diff --git a/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py b/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py index 8326aa02..c33f5d6c 100644 --- a/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py +++ b/module_utils/ha_cluster_lsr/pcs_api_v2_utils.py @@ -21,7 +21,7 @@ from http.client import HTTPResponse from json import JSONDecodeError -from typing import Any, Mapping, Union +from typing import Any, Mapping, Optional, Union from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.urls import fetch_url @@ -30,7 +30,7 @@ from dacite import DaciteError except ImportError: HAS_DACITE = False - DACITE_IMPORT_ERROR = traceback.format_exc() + DACITE_IMPORT_ERROR: Optional[str] = traceback.format_exc() else: HAS_DACITE = True DACITE_IMPORT_ERROR = None @@ -46,19 +46,24 @@ from pcs.common.reports import ReportItemDto, ReportItemSeverity except ImportError: HAS_PCS = False - PCS_IMPORT_ERROR = traceback.format_exc() + PCS_IMPORT_ERROR: Optional[str] = traceback.format_exc() - class CommandOptionsDto(object): - def __init__(self, **kwargs): + # These classes need to be available and imported above to do linting + # properly, linters can be safely silenced for these stubs. + + # pylint: disable=missing-class-docstring + # pylint: disable=too-few-public-methods + class CommandOptionsDto: # type: ignore + def __init__(self, **kwargs): # type: ignore pass - class ReportItemDto(object): + class ReportItemDto: # type: ignore pass - class TaskResultDto(object): + class TaskResultDto: # type: ignore pass - class CommandDto(object): + class CommandDto: # type: ignore pass else: