From 0e3c88b7371ea6b3311aa7cc49b4b62f9f9f0fc3 Mon Sep 17 00:00:00 2001 From: Stanislav Pankevich Date: Sat, 27 Apr 2024 17:19:52 +0200 Subject: [PATCH] Code climate: set mypy to --strict mode, ignore appeared checks for now Related to: #144 --- reqif/helpers/lxml.py | 8 ++++++-- reqif/models/reqif_spec_object_type.py | 2 +- reqif/reqif_bundle.py | 2 +- tasks.py | 7 ++++++- .../examples/04_convert_reqif_to_json/script.py | 3 +-- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/reqif/helpers/lxml.py b/reqif/helpers/lxml.py index d699366..d3333ad 100644 --- a/reqif/helpers/lxml.py +++ b/reqif/helpers/lxml.py @@ -183,13 +183,17 @@ def lxml_convert_to_reqif_ns_xhtml_string(string, reqif_xhtml=True) -> str: def lxml_convert_from_reqif_ns_xhtml_string(lxml_node) -> str: lxml_node_deep_copy = deepcopy(lxml_node) lxml_strip_namespace_from_xml(lxml_node_deep_copy, full=True) - return tostring(lxml_node_deep_copy, encoding=str, pretty_print=True).rstrip() + result: str = tostring( + lxml_node_deep_copy, encoding=str, pretty_print=True + ).rstrip() + return result def lxml_convert_children_from_reqif_ns_xhtml_string(lxml_node) -> str: lxml_node_deep_copy = deepcopy(lxml_node) lxml_strip_namespace_from_xml(lxml_node_deep_copy, full=True) - return lxml_stringify_children(lxml_node_deep_copy) + result: str = lxml_stringify_children(lxml_node_deep_copy) + return result def lxml_is_self_closed_tag(xml): diff --git a/reqif/models/reqif_spec_object_type.py b/reqif/models/reqif_spec_object_type.py index 8334982..58c63e5 100644 --- a/reqif/models/reqif_spec_object_type.py +++ b/reqif/models/reqif_spec_object_type.py @@ -19,7 +19,7 @@ def __init__( # pylint: disable=too-many-arguments description: Optional[str] = None, last_change: Optional[str] = None, long_name: Optional[str] = None, - editable: Optional[bool] = None, + editable: Optional[str] = None, default_value_definition_ref: Optional[str] = None, default_value: Union[None, DefaultValueEmptySelfClosedTag, str] = None, multi_valued: Optional[bool] = None, diff --git a/reqif/reqif_bundle.py b/reqif/reqif_bundle.py index 026f5a8..eae32a1 100644 --- a/reqif/reqif_bundle.py +++ b/reqif/reqif_bundle.py @@ -1,5 +1,5 @@ import collections -from typing import Deque, Dict, Iterator, List, Optional, Any +from typing import Any, Deque, Dict, Iterator, List, Optional from reqif.helpers.debug import auto_described from reqif.models.error_handling import ReqIFSchemaError diff --git a/tasks.py b/tasks.py index dcc8a79..b280fb1 100644 --- a/tasks.py +++ b/tasks.py @@ -147,8 +147,13 @@ def lint_mypy(context): mypy reqif/ --show-error-codes --disable-error-code=import + --disable-error-code=arg-type --disable-error-code=no-untyped-call - """, # --strict + --disable-error-code=no-untyped-def + --disable-error-code=type-arg + --disable-error-code=union-attr + --strict + """, ) diff --git a/tests/integration/examples/04_convert_reqif_to_json/script.py b/tests/integration/examples/04_convert_reqif_to_json/script.py index 821b69b..e7b0c3b 100644 --- a/tests/integration/examples/04_convert_reqif_to_json/script.py +++ b/tests/integration/examples/04_convert_reqif_to_json/script.py @@ -3,7 +3,7 @@ import os from dataclasses import dataclass, field from pathlib import Path -from typing import Any, Dict, List, Optional +from typing import Dict, List, Optional from dataclasses_json import dataclass_json @@ -15,7 +15,6 @@ ReqIFDataTypeDefinitionXHTML, ) from reqif.models.reqif_spec_object import ReqIFSpecObject -from reqif.models.reqif_specification import ReqIFSpecification from reqif.parser import ReqIFParser, ReqIFZParser from reqif.reqif_bundle import ReqIFBundle, ReqIFZBundle