Skip to content

Commit 6ca320b

Browse files
thseilerstanislaw
authored andcommitted
code-climate: mypy: address type-arg: SourceFileTraceabilityInfo/Parts
1 parent dfd8153 commit 6ca320b

File tree

4 files changed

+29
-14
lines changed

4 files changed

+29
-14
lines changed

strictdoc/backend/sdoc_source_code/models/function_range_marker.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-def,type-arg"
1+
# mypy: disable-error-code="no-untyped-def"
22
from copy import copy
33
from enum import Enum
44
from typing import List, Optional

strictdoc/backend/sdoc_source_code/models/range_marker.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# mypy: disable-error-code="no-untyped-def,type-arg"
21
from typing import Any, List, Optional
32

43
from strictdoc.backend.sdoc_source_code.models.requirement_marker import Req
@@ -14,7 +13,7 @@ def __init__(
1413
reqs_objs: List[Req],
1514
scope: str = "",
1615
role: Optional[str] = None,
17-
):
16+
) -> None:
1817
assert isinstance(reqs_objs, list)
1918
self.parent: Any = parent
2019
assert len(begin_or_end) > 0 or scope is not None
@@ -115,12 +114,15 @@ def get_description(self) -> Optional[str]:
115114
@auto_described
116115
class ForwardRangeMarker:
117116
def __init__(
118-
self, start_or_end: bool, reqs_objs: List, role: Optional[str] = None
119-
):
117+
self,
118+
start_or_end: bool,
119+
reqs_objs: List[Req],
120+
role: Optional[str] = None,
121+
) -> None:
120122
assert len(reqs_objs) > 0
121123
self.start_or_end: bool = start_or_end
122124

123-
self.reqs_objs: List[str] = reqs_objs
125+
self.reqs_objs: List[Req] = reqs_objs
124126
self.reqs: List[str] = list(map(lambda req: req.uid, reqs_objs))
125127

126128
self.role: Optional[str] = (
@@ -156,7 +158,9 @@ def is_forward(self) -> bool:
156158

157159
@auto_described
158160
class ForwardFileMarker(ForwardRangeMarker):
159-
def __init__(self, reqs_objs: List, role: Optional[str] = None):
161+
def __init__(
162+
self, reqs_objs: List[Req], role: Optional[str] = None
163+
) -> None:
160164
super().__init__(True, reqs_objs, role)
161165

162166
def get_description(self) -> Optional[str]:

strictdoc/backend/sdoc_source_code/models/source_file_info.py

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

44
from typing_extensions import TypeAlias
55

@@ -23,15 +23,20 @@
2323

2424
@auto_described
2525
class SourceFileTraceabilityInfo:
26-
def __init__(self, g_parts: List):
26+
def __init__(self, g_parts: List[Any]): # noqa: ARG002
2727
"""
2828
At the init time, only the backward RangeMarkers are available from
2929
a source file. At runtime, the ForwardRangeMarkers are mixed in
3030
from the Requirement/FileReference links. This is why the .markers
3131
is a union.
32+
33+
Note that g_parts is only used by the textX grammar to allow the
34+
definition of the child grammar elements. All other instance variables
35+
of this class are not using or based on g_parts. Instead, they are
36+
populated during the textX processing step, e.g., via
37+
general_language_marker_processors.py.
3238
"""
3339

34-
self.g_parts: List = g_parts
3540
self.source_file: Optional[SourceFile] = None
3641
self.functions: List[Function] = []
3742

strictdoc/backend/sdoc_source_code/reader.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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 functools import partial
5-
from typing import List, Optional
5+
from typing import List, Optional, TypedDict
66

77
from textx import get_location, metamodel_from_str
88

@@ -24,6 +24,12 @@
2424
from strictdoc.helpers.textx import drop_textx_meta
2525

2626

27+
class TextXLocation(TypedDict):
28+
line: int
29+
col: int
30+
filename: str
31+
32+
2733
def req_processor(req: Req):
2834
assert isinstance(req, Req), (
2935
f"Expected req to be Req, got: {req}, {type(req)}"
@@ -95,7 +101,7 @@ def create_end_without_begin_error(location):
95101
def create_unmatch_range_error(unmatched_ranges: List[RangeMarker]):
96102
assert isinstance(unmatched_ranges, list)
97103
assert len(unmatched_ranges) > 0
98-
range_locations: List = []
104+
range_locations: List[TextXLocation] = []
99105
for unmatched_range in unmatched_ranges:
100106
location = get_location(unmatched_range)
101107
range_locations.append(location)

0 commit comments

Comments
 (0)