Skip to content

Commit bf6e54c

Browse files
committed
code-climate: mypy: address type-arg
1 parent 6d293f3 commit bf6e54c

File tree

15 files changed

+72
-46
lines changed

15 files changed

+72
-46
lines changed

strictdoc/backend/excel/export/excel_generator.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# mypy: disable-error-code="arg-type,no-untyped-def,type-arg,union-attr"
1+
# mypy: disable-error-code="arg-type,no-untyped-def,union-attr"
22
import os
33
from pathlib import Path
44
from typing import Dict, List
@@ -8,6 +8,7 @@
88
from xlsxwriter.worksheet import Worksheet
99

1010
from strictdoc.backend.sdoc.models.document import SDocDocument
11+
from strictdoc.backend.sdoc.models.model import SDocElementIF
1112
from strictdoc.backend.sdoc.models.node import SDocNode
1213
from strictdoc.backend.sdoc.models.reference import (
1314
FileReference,
@@ -224,7 +225,7 @@ def _export_single_document(
224225
os.unlink(document_out_file)
225226

226227
@staticmethod
227-
def _lookup_refs(document_contents: List) -> Dict[str, int]:
228+
def _lookup_refs(document_contents: List[SDocElementIF]) -> Dict[str, int]:
228229
refs: Dict[str, int] = {}
229230
row = 1
230231

@@ -260,8 +261,8 @@ def _set_columns_width(
260261
worksheet.set_column(idx, idx, columns[field][MAX_WIDTH_KEY])
261262

262263
@staticmethod
263-
def _init_headers(fields: List[str]) -> List:
264-
headers: List = []
264+
def _init_headers(fields: List[str]) -> List[str]:
265+
headers: List[str] = []
265266

266267
for field in fields:
267268
headers.append({"header": field.upper()})

strictdoc/backend/reqif/p01_sdoc/sdoc_to_reqif_converter.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# mypy: disable-error-code="no-untyped-call,no-untyped-def,type-arg,union-attr"
1+
# mypy: disable-error-code="no-untyped-call,no-untyped-def,union-attr"
22
import datetime
33
import uuid
44
from collections import defaultdict
@@ -102,11 +102,11 @@ def convert_document_tree(
102102
multiline_is_xhtml=multiline_is_xhtml, enable_mid=enable_mid
103103
)
104104

105-
spec_types: List = []
105+
spec_types: List[ReqIFSpecificationType] = []
106106
spec_objects: List[ReqIFSpecObject] = []
107107
spec_relations: List[ReqIFSpecRelation] = []
108108
specifications: List[ReqIFSpecification] = []
109-
data_types: List = []
109+
data_types: List[ReqIFDataTypeDefinitionString] = []
110110
data_types_lookup = {}
111111

112112
specification_type = ReqIFSpecificationType(
@@ -478,7 +478,7 @@ def _convert_requirement_to_spec_object(
478478
requirement: SDocNode,
479479
grammar: DocumentGrammar,
480480
context: P01_SDocToReqIFBuildContext,
481-
data_types: List,
481+
data_types: List[ReqIFDataTypeDefinitionString],
482482
data_types_lookup: Dict[str, str],
483483
) -> ReqIFSpecObject:
484484
node_document = assert_cast(requirement.get_document(), SDocDocument)
@@ -602,7 +602,7 @@ def _convert_document_grammar_to_spec_types(
602602
data_types_lookup,
603603
context: P01_SDocToReqIFBuildContext,
604604
):
605-
spec_object_types: List = []
605+
spec_object_types: List[ReqIFSpecificationType] = []
606606

607607
grammar_document: SDocDocument = assert_cast(
608608
grammar.parent, SDocDocument
@@ -699,14 +699,16 @@ def _convert_document_grammar_to_spec_types(
699699
spec_object_types.append(section_spec_type)
700700

701701
# Using dict as an ordered set.
702-
spec_relation_tuples: OrderedSet = OrderedSet()
702+
spec_relation_tuples: OrderedSet[Tuple[str, Optional[str]]] = (
703+
OrderedSet()
704+
)
703705
for element_ in grammar.elements:
704706
for relation_ in element_.relations:
705707
spec_relation_tuples.add(
706708
(relation_.relation_type, relation_.relation_role)
707709
)
708710

709-
spec_relation_types: List = []
711+
spec_relation_types: List[ReqIFSpecRelationType] = []
710712
for spec_relation_tuple_ in spec_relation_tuples:
711713
spec_relation_type_name = (
712714
spec_relation_tuple_[1]

strictdoc/backend/sdoc/models/document_grammar.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# mypy: disable-error-code="no-untyped-call,union-attr,type-arg"
1+
# mypy: disable-error-code="no-untyped-call,union-attr"
22
from collections import OrderedDict
33
from typing import Dict, Generator, List, Optional, Set, Tuple, Union
44

@@ -35,7 +35,13 @@ def __init__(
3535
GrammarElementFieldSingleChoice,
3636
]
3737
],
38-
relations: List,
38+
relations: List[
39+
Union[
40+
GrammarElementRelationParent,
41+
GrammarElementRelationChild,
42+
GrammarElementRelationFile,
43+
]
44+
],
3945
) -> None:
4046
self.parent: Optional[DocumentGrammar] = parent
4147
self.tag: str = tag
@@ -81,7 +87,7 @@ def __init__(
8187
GrammarElementRelationFile,
8288
]
8389
] = relations if relations is not None and len(relations) > 0 else []
84-
fields_map: OrderedDict = OrderedDict()
90+
fields_map: OrderedDict[str, GrammarElementField] = OrderedDict()
8591

8692
statement_field: Optional[Tuple[str, int]] = None
8793
description_field: Optional[Tuple[str, int]] = None

strictdoc/backend/sdoc/processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# mypy: disable-error-code="arg-type,attr-defined,no-untyped-call,no-untyped-def,union-attr,type-arg"
1+
# mypy: disable-error-code="arg-type,attr-defined,no-untyped-call,no-untyped-def,union-attr"
22
import os.path
33
from typing import List, Optional
44

strictdoc/backend/sdoc/writer.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# mypy: disable-error-code="arg-type,attr-defined,no-untyped-call,no-untyped-def,union-attr,type-arg"
1+
# mypy: disable-error-code="arg-type,attr-defined,no-untyped-call,no-untyped-def,union-attr"
22
import os.path
33
from pathlib import Path
44
from typing import Dict, List, Tuple, Union
@@ -27,6 +27,9 @@
2727
GrammarElementFieldSingleChoice,
2828
GrammarElementFieldString,
2929
GrammarElementFieldTag,
30+
GrammarElementRelationChild,
31+
GrammarElementRelationFile,
32+
GrammarElementRelationParent,
3033
RequirementFieldType,
3134
)
3235
from strictdoc.core.document_iterator import DocumentCachingIterator
@@ -262,7 +265,13 @@ def write_with_fragments(
262265
grammar_field
263266
)
264267

265-
relations: List = element.relations
268+
relations: List[
269+
Union[
270+
GrammarElementRelationParent,
271+
GrammarElementRelationChild,
272+
GrammarElementRelationFile,
273+
]
274+
] = element.relations
266275
if len(relations) > 0:
267276
output += " RELATIONS:\n"
268277

strictdoc/backend/sdoc_source_code/reader_c.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# mypy: disable-error-code="no-untyped-call,no-untyped-def,type-arg"
1+
# mypy: disable-error-code="no-untyped-call,no-untyped-def"
22
import sys
33
import traceback
44
from typing import List, Optional, Sequence, Union

strictdoc/backend/sdoc_source_code/reader_python.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# mypy: disable-error-code="no-untyped-call,no-untyped-def,type-arg"
1+
# mypy: disable-error-code="no-untyped-call,no-untyped-def"
22
import sys
33
import traceback
44
from itertools import islice

strictdoc/core/graph/many_to_many_set.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from copy import copy
2-
from typing import Any, Dict, List, Optional, Tuple
2+
from typing import Any, Dict, List, Optional, Tuple, Type
33

44
from strictdoc.core.graph.abstract_bucket import ALL_EDGES, AbstractBucket
55
from strictdoc.helpers.ordered_set import OrderedSet
66

77

88
class ManyToManySet(AbstractBucket):
9-
def __init__(self, lhs_type: type, rhs_type: type) -> None:
9+
def __init__(self, lhs_type: Type[Any], rhs_type: Type[Any]) -> None:
1010
self._links: Dict[Any, Dict[Optional[str], OrderedSet[Any]]] = {}
1111
self._links_reverse: Dict[
1212
Any, Dict[Optional[str], OrderedSet[Any]]

strictdoc/core/graph/one_to_one_dictionary.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
# mypy: disable-error-code="no-untyped-def,type-arg"
1+
# mypy: disable-error-code="no-untyped-def"
22
from typing import Any, Dict, Optional, Tuple, Type, Union
33

44
from strictdoc.core.graph.abstract_bucket import AbstractBucket
55

66

77
class OneToOneDictionary(AbstractBucket):
8-
def __init__(self, lhs_type: Type, rhs_type: Union[Type, Tuple]):
9-
self._dict: Dict = {}
10-
self._lhs_type: Type = lhs_type
11-
self._rhs_type: Union[Type, Tuple] = rhs_type
8+
def __init__(
9+
self,
10+
lhs_type: Type[Any],
11+
rhs_type: Union[Type[Any], Tuple[Type[Any], ...]],
12+
):
13+
self._dict: Dict[Any, Any] = {}
14+
self._lhs_type: Type[Any] = lhs_type
15+
self._rhs_type: Union[Type[Any], Tuple[Type[Any], ...]] = rhs_type
1216

1317
def has_link(self, *, lhs_node: Any) -> bool:
1418
assert isinstance(lhs_node, self._lhs_type), (lhs_node, self._lhs_type)

strictdoc/core/graph_database.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# mypy: disable-error-code="no-untyped-def,type-arg"
1+
# mypy: disable-error-code="no-untyped-def"
22
from typing import Any, Dict, Hashable, List, Optional, Tuple
33

44
from strictdoc.core.graph.abstract_bucket import AbstractBucket
@@ -40,7 +40,7 @@ def get_link_value(
4040

4141
def get_link_values(
4242
self, *, link_type: Hashable, lhs_node: Any, edge: Optional[str] = None
43-
) -> OrderedSet:
43+
) -> OrderedSet[Any]:
4444
return self._id_to_bucket[link_type].get_link_values(
4545
lhs_node=lhs_node, edge=edge
4646
)

0 commit comments

Comments
 (0)