Skip to content

Commit f4d3e1b

Browse files
committed
code-climate: remove @Property from is_requirement() & co
1 parent d2cdcc6 commit f4d3e1b

File tree

26 files changed

+118
-115
lines changed

26 files changed

+118
-115
lines changed

strictdoc/backend/excel/export/excel_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def _export_single_document(
9090
).all_content(
9191
print_fragments=False, print_fragments_from_files=False
9292
):
93-
if not node.is_requirement or not node.reserved_uid:
93+
if not node.is_requirement() or not node.reserved_uid:
9494
# only export the requirements with uid
9595
continue
9696

strictdoc/backend/reqif/p01_sdoc/sdoc_to_reqif_converter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,13 @@ def convert_document_tree(
249249
for node_ in document_iterator.all_content(
250250
print_fragments=False, print_fragments_from_files=False
251251
):
252-
if node_.is_composite_requirement:
252+
if node_.is_composite_requirement():
253253
raise NotImplementedError(
254254
"Exporting composite requirements is not "
255255
"supported yet.",
256256
node_,
257257
)
258-
if node_.is_section:
258+
if node_.is_section():
259259
section: SDocSection = assert_cast(node_, SDocSection)
260260
# fmt: off
261261
spec_object = (
@@ -294,7 +294,7 @@ def convert_document_tree(
294294
parents[hierarchy] = current_hierarchy_parent
295295
current_hierarchy = hierarchy
296296

297-
elif node_.is_requirement:
297+
elif node_.is_requirement():
298298
requirement = assert_cast(node_, SDocNode)
299299
spec_object = cls._convert_requirement_to_spec_object(
300300
requirement=requirement,

strictdoc/backend/sdoc/models/document.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,16 @@ def __init__(
8181
def uid(self) -> Optional[str]:
8282
return self.config.uid
8383

84-
@property
8584
def is_section(self) -> bool:
8685
return True
8786

8887
@property
8988
def is_root_included_document(self) -> bool:
9089
return self.document_is_included()
9190

92-
@property
9391
def is_requirement(self) -> bool:
9492
return False
9593

96-
@property
9794
def is_composite_requirement(self) -> bool:
9895
return False
9996

strictdoc/backend/sdoc/models/node.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,6 @@ def rationale(self) -> Optional[str]:
301301
RequirementFieldName.RATIONALE, singleline_only=False
302302
)
303303

304-
# Other properties
305-
# FIXME: Remove @property.
306-
@property
307304
def is_requirement(self) -> bool:
308305
return True
309306

@@ -313,26 +310,15 @@ def is_normative_node(self) -> bool:
313310
def is_text_node(self) -> bool:
314311
return self.node_type == "TEXT"
315312

316-
# FIXME: Remove @property.
317-
@property
318313
def is_section(self) -> bool:
319314
return False
320315

321-
# FIXME: Remove @property.
322-
@property
323316
def is_document(self) -> bool:
324317
return False
325318

326-
# FIXME: Remove @property.
327-
@property
328319
def is_composite_requirement(self) -> bool:
329320
return False
330321

331-
# FIXME: Remove this, use get_document().
332-
@property
333-
def document(self) -> Optional[SDocDocumentIF]:
334-
return self.get_document()
335-
336322
def get_document(self) -> Optional[SDocDocumentIF]:
337323
assert self.ng_document_reference is not None, self
338324
return self.ng_document_reference.get_document()
@@ -695,7 +681,6 @@ def __init__(
695681
) -> None:
696682
super().__init__(parent, **fields)
697683

698-
@property
699684
def is_composite_requirement(self) -> bool:
700685
return True
701686

strictdoc/backend/sdoc/models/object_factory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ def create_requirement(
134134
if isinstance(parent, SDocDocument):
135135
requirement.ng_document_reference.set_document(parent)
136136
else:
137-
requirement.ng_document_reference.set_document(parent.document)
137+
requirement.ng_document_reference.set_document(
138+
parent.get_document()
139+
)
138140
return requirement
139141

140142
@staticmethod

strictdoc/backend/sdoc/models/section.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
SDocSectionIF,
1313
)
1414
from strictdoc.helpers.auto_described import auto_described
15+
from strictdoc.helpers.cast import assert_cast
1516
from strictdoc.helpers.mid import MID
1617

1718

@@ -76,10 +77,9 @@ def get_node_type_string(self) -> Optional[str]:
7677

7778
def get_debug_info(self) -> str:
7879
debug_components: List[str] = [f"TITLE = '{self.title}'"]
79-
if self.document is not None:
80-
debug_components.append(
81-
f"document = {self.document.get_debug_info()}"
82-
)
80+
document: Optional[SDocDocumentIF] = self.get_document()
81+
if document is not None:
82+
debug_components.append(f"document = {document.get_debug_info()}")
8383
return f"Section({', '.join(debug_components)})"
8484

8585
@property
@@ -91,11 +91,6 @@ def get_display_title(self, include_toc_number: bool = True) -> str:
9191
return f"{self.context.title_number_string}. {self.title}"
9292
return self.title
9393

94-
# FIXME: Remove this method, use get_document() instead.
95-
@property
96-
def document(self) -> Optional[SDocDocumentIF]:
97-
return self.ng_document_reference.get_document()
98-
9994
def get_document(self) -> Optional[SDocDocumentIF]:
10095
return self.ng_document_reference.get_document()
10196

@@ -121,15 +116,12 @@ def parent_or_including_document(self) -> SDocDocumentIF:
121116
def document_is_included(self):
122117
return self.ng_including_document_reference.get_document() is not None
123118

124-
@property
125119
def is_requirement(self):
126120
return False
127121

128-
@property
129122
def is_composite_requirement(self):
130123
return False
131124

132-
@property
133125
def is_section(self):
134126
return True
135127

@@ -141,7 +133,10 @@ def has_any_text_nodes(self):
141133

142134
@property
143135
def is_root(self) -> bool:
144-
return self.document.config.root is True
136+
document: SDocDocumentIF = assert_cast(
137+
self.get_document(), SDocDocumentIF
138+
)
139+
return document.config.root is True
145140

146141
def get_requirement_prefix(self) -> str:
147142
if self.requirement_prefix is not None:

strictdoc/core/file_traceability_index.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,10 @@ def marker_comparator(marker):
612612

613613
# validate here, SDocNode.relations doesn't track marker roles
614614
node = traceability_index.get_node_by_uid(req_uid_)
615-
assert node.document and node.document.grammar
616-
grammar_element = node.document.grammar.elements_by_type[
615+
document = node.get_document()
616+
assert document is not None
617+
assert document.grammar is not None
618+
grammar_element = document.grammar.elements_by_type[
617619
node.node_type
618620
]
619621
for marker in markers_:

strictdoc/core/query_engine/query_object.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def _evaluate_node_field_expression(
200200
self, node, expression: NodeFieldExpression
201201
) -> Optional[str]:
202202
field_name = expression.field_name
203-
if node.is_requirement and node.node_type == "REQUIREMENT":
203+
if node.is_requirement() and node.node_type == "REQUIREMENT":
204204
requirement: SDocNode = assert_cast(node, SDocNode)
205205
requirement_document: SDocDocument = assert_cast(
206206
requirement.get_document(), SDocDocument
@@ -217,7 +217,7 @@ def _evaluate_node_field_expression(
217217
if field_value is not None:
218218
return field_value
219219
return None
220-
elif node.is_section:
220+
elif node.is_section():
221221
section: SDocSection = assert_cast(node, SDocSection)
222222
if field_name == "UID":
223223
return section.reserved_uid

strictdoc/core/traceability_index_builder.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def create_from_document_tree(
452452
rhs_node=node,
453453
)
454454

455-
if node.is_requirement:
455+
if node.is_requirement():
456456
requirement: SDocNode = assert_cast(node, SDocNode)
457457
if requirement.reserved_tags is not None:
458458
for tag in requirement.reserved_tags:
@@ -486,7 +486,7 @@ def create_from_document_tree(
486486
print_fragments=False,
487487
print_fragments_from_files=False,
488488
):
489-
if not node.is_requirement:
489+
if not node.is_requirement():
490490
continue
491491

492492
requirement: SDocNode = node
@@ -628,7 +628,7 @@ def create_from_document_tree(
628628
print_fragments=False,
629629
print_fragments_from_files=False,
630630
):
631-
if not node.is_requirement:
631+
if not node.is_requirement():
632632
continue
633633
requirement: Union[SDocNode, SDocCompositeNode] = assert_cast(
634634
node, (SDocNode, SDocCompositeNode)
@@ -803,7 +803,7 @@ def _filter_nodes(
803803
node.parent.blacklist_if_needed()
804804

805805
elif (
806-
node.is_requirement
806+
node.is_requirement()
807807
and not requirements_query_object.evaluate(node)
808808
):
809809
node.ng_whitelisted = False
@@ -816,7 +816,7 @@ def _filter_nodes(
816816
]
817817
== node
818818
):
819-
if node.parent.is_section:
819+
if node.parent.is_section():
820820
node.parent.blacklist_if_needed()
821821

822822
except (AttributeError, NameError, TypeError) as attribute_error_:

strictdoc/core/transforms/update_grammar_element.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def perform(self) -> bool:
8484
document_iterator = self.traceability_index.document_iterators[document]
8585

8686
for node in document_iterator.all_content():
87-
if not node.is_requirement:
87+
if not node.is_requirement():
8888
continue
8989

9090
requirement: SDocNode = assert_cast(node, SDocNode)

0 commit comments

Comments
 (0)