Skip to content

Commit 5e54f90

Browse files
authored
Merge pull request #2253 from thseiler/code-climate/address-no-any-return
code-climate: mypy address some no-any-return
2 parents 75c839a + c7161c7 commit 5e54f90

26 files changed

+58
-49
lines changed

strictdoc/backend/sdoc/models/section.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,16 @@ def parent_or_including_document(self) -> SDocDocumentIF:
115115
def document_is_included(self):
116116
return self.ng_including_document_reference.get_document() is not None
117117

118-
def is_requirement(self):
118+
def is_requirement(self) -> bool:
119119
return False
120120

121-
def is_composite_requirement(self):
121+
def is_composite_requirement(self) -> bool:
122122
return False
123123

124-
def is_section(self):
124+
def is_section(self) -> bool:
125125
return True
126126

127-
def has_any_text_nodes(self):
127+
def has_any_text_nodes(self) -> bool:
128128
return any(
129129
node_.__class__.__name__ == "SDocNode" and node_.node_type == "TEXT"
130130
for node_ in self.section_contents

strictdoc/backend/sdoc/reader.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-any-return,no-untyped-call,no-untyped-def"
1+
# mypy: disable-error-code="no-untyped-call,no-untyped-def"
22
import sys
33
import traceback
44
from copy import copy

strictdoc/core/environment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ def __init__(self, path_to_init: str):
4646
f"{self.path_to_strictdoc}"
4747
)
4848

49-
def get_static_files_path(self):
49+
def get_static_files_path(self) -> str:
5050
if self.is_binary_dist: # pragma: no cover
5151
return os.path.join(self.path_to_strictdoc, "_static")
5252
return os.path.join(
5353
self.path_to_strictdoc, "strictdoc/export/html/_static"
5454
)
5555

56-
def get_extra_static_files_path(self):
56+
def get_extra_static_files_path(self) -> str:
5757
if self.is_binary_dist: # pragma: no cover
5858
return os.path.join(self.path_to_strictdoc, "_static_extra")
5959
return os.path.join(

strictdoc/core/file_traceability_index.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-any-return,no-untyped-def"
1+
# mypy: disable-error-code="arg-type,attr-defined,no-untyped-def"
22
from copy import copy
33
from typing import Any, Dict, Iterator, List, Optional, Set, Tuple, Union
44

strictdoc/core/file_tree.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# mypy: disable-error-code="no-any-return,no-untyped-call,no-untyped-def"
1+
# mypy: disable-error-code="no-untyped-call,no-untyped-def"
22
import collections
33
import functools
44
import os
@@ -24,16 +24,16 @@ def mount_folder(self):
2424

2525

2626
class File(FileOrFolderEntry):
27-
def __init__(self, level, full_path, rel_path: SDocRelativePath):
27+
def __init__(self, level: int, full_path: str, rel_path: SDocRelativePath):
2828
assert os.path.isfile(full_path)
2929
assert os.path.isabs(full_path)
3030
assert isinstance(rel_path, SDocRelativePath)
3131

32-
self.level = level
33-
self.full_path = full_path
34-
self.root_path = full_path
32+
self.level: int = level
33+
self.full_path: str = full_path
34+
self.root_path: str = full_path
3535
self.rel_path: SDocRelativePath = rel_path
36-
self.file_name = os.path.basename(self.full_path)
36+
self.file_name: str = os.path.basename(self.full_path)
3737
self.files = [self]
3838
self.subfolder_trees: List[Folder] = []
3939

strictdoc/core/graph/abstract_bucket.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
from abc import ABC, abstractmethod
33
from typing import Any, List, Optional, Tuple
44

5+
from strictdoc.helpers.ordered_set import OrderedSet
6+
57
ALL_EDGES = ".all"
68

79

@@ -26,7 +28,7 @@ def get_link_value_weak(self, *, lhs_node: Any) -> Optional[Any]:
2628

2729
def get_link_values(
2830
self, *, lhs_node: Any, edge: Optional[str] = None
29-
) -> Any:
31+
) -> OrderedSet[Any]:
3032
raise NotImplementedError # pragma: no cover
3133

3234
def get_link_values_with_edges(

strictdoc/core/graph_database.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-any-return,no-untyped-def,type-arg"
1+
# mypy: disable-error-code="no-untyped-def,type-arg"
22
from typing import Any, Dict, Hashable, List, Optional, Tuple
33

44
from strictdoc.core.graph.abstract_bucket import AbstractBucket

strictdoc/core/project_config.py

Lines changed: 2 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-any-return,no-untyped-call,no-untyped-def,type-arg"
1+
# mypy: disable-error-code="arg-type,attr-defined,no-untyped-call,no-untyped-def,type-arg"
22
import datetime
33
import os
44
import re
@@ -195,7 +195,7 @@ def __init__(
195195
self.chromedriver: Optional[str] = chromedriver
196196

197197
@staticmethod
198-
def default_config(environment: SDocRuntimeEnvironment):
198+
def default_config(environment: SDocRuntimeEnvironment) -> "ProjectConfig":
199199
assert isinstance(environment, SDocRuntimeEnvironment)
200200
return ProjectConfig(
201201
environment=environment,

strictdoc/core/query_engine/query_object.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def _evaluate_node_field_expression(
227227
else:
228228
raise NotImplementedError # pragma: no cover
229229

230-
def _evaluate_node_has_parent_requirements(self, node):
230+
def _evaluate_node_has_parent_requirements(self, node) -> bool:
231231
if not isinstance(node, SDocNode):
232232
raise TypeError(
233233
f"node.has_parent_requirements can be only called on "
@@ -236,7 +236,7 @@ def _evaluate_node_has_parent_requirements(self, node):
236236
)
237237
return self.traceability_index.has_parent_requirements(node)
238238

239-
def _evaluate_node_has_child_requirements(self, node):
239+
def _evaluate_node_has_child_requirements(self, node) -> bool:
240240
if not isinstance(node, SDocNode):
241241
raise TypeError(
242242
f"node.has_child_requirements can be only called on "
@@ -262,7 +262,7 @@ def _evaluate_node_contains(
262262
return False
263263
raise NotImplementedError # pragma: no cover
264264

265-
def _evaluate_node_contains_any_text(self, node):
265+
def _evaluate_node_contains_any_text(self, node) -> bool:
266266
if not isinstance(node, SDocSection):
267267
raise TypeError(
268268
f"node.contains_any_text can be only called on "

strictdoc/core/traceability_index.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# mypy: disable-error-code="arg-type,attr-defined,no-any-return,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,type-arg"
22
import datetime
33
from copy import deepcopy
44
from typing import Any, Dict, Generator, List, Optional, Tuple, Union
@@ -64,7 +64,7 @@ def __init__(
6464
)
6565

6666
@property
67-
def document_iterators(self):
67+
def document_iterators(self) -> Dict[SDocDocument, DocumentCachingIterator]:
6868
return self._document_iterators
6969

7070
def is_small_project(self):
@@ -106,7 +106,7 @@ def has_parent_requirements(self, requirement: SDocNode) -> bool:
106106
)
107107
return len(parent_requirements) > 0
108108

109-
def has_children_requirements(self, requirement: SDocNode):
109+
def has_children_requirements(self, requirement: SDocNode) -> bool:
110110
assert isinstance(requirement, SDocNode)
111111
if not isinstance(requirement.reserved_uid, str):
112112
return False

0 commit comments

Comments
 (0)