Skip to content

Commit b2f1260

Browse files
committed
code-climate: mypy: address remaining arg-type: review findings
1 parent 7264e3d commit b2f1260

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

strictdoc/core/actions/export_action.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ def export(self) -> None:
7474
# The bundle document is generated only when the option is provided.
7575
traceability_index_copy: Optional[TraceabilityIndex] = None
7676
bundle_document: Optional[SDocDocument] = None
77+
if self.project_config.generate_bundle_document:
78+
traceability_index_copy, bundle_document = (
79+
self.traceability_index.clone_to_bundle_document(
80+
self.project_config
81+
)
82+
)
7783

7884
if (
7985
"html" in self.project_config.export_formats
@@ -87,11 +93,6 @@ def export(self) -> None:
8793
parallelizer=self.parallelizer,
8894
)
8995
if self.project_config.generate_bundle_document:
90-
traceability_index_copy, bundle_document = (
91-
self.traceability_index.clone_to_bundle_document(
92-
self.project_config
93-
)
94-
)
9596
assert bundle_document is not None, (
9697
"bundle_document must not be None."
9798
)

strictdoc/core/traceability_index_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ def create(
8585
latest_strictdoc_own_file = (
8686
max(strict_own_files, key=os.path.getctime)
8787
if len(strict_own_files) > 0
88-
else ""
88+
else None
8989
)
9090

9191
strictdoc_last_update: datetime.datetime = (
9292
get_file_modification_time(latest_strictdoc_own_file)
93-
if (latest_strictdoc_own_file != "")
93+
if (latest_strictdoc_own_file is not None)
9494
else datetime.datetime.fromtimestamp(0)
9595
)
9696
if (

strictdoc/export/spdx/spdx_generator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ def get_spdx_ref(node: Union[SDocDocument, SDocNode, str]) -> str:
8383
elif node.reserved_title is not None:
8484
identifier = re.sub(r"[ #-/\\]", "_", node.reserved_title)
8585
else:
86-
raise RuntimeError("Cannot create unique identifier for this node.")
86+
raise RuntimeError(
87+
f"Cannot create unique identifier for this node: {node}"
88+
)
8789

8890
if isinstance(node, SDocDocument):
8991
return "SDocDocument-" + identifier

strictdoc/git/project_diff_analyzer.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -824,15 +824,15 @@ def create_comment_field_changes(
824824

825825
changes = []
826826

827-
changed_fields: Set[SDocNodeField] = set(
828-
requirement.ordered_fields_lookup.get("COMMENT", [])
827+
changed_fields: Dict[SDocNodeField, None] = dict.fromkeys(
828+
requirement.ordered_fields_lookup.get("COMMENT", []), None
829829
)
830-
changed_other_fields: Set[SDocNodeField] = set(
831-
other_requirement.ordered_fields_lookup.get("COMMENT", [])
830+
changed_other_fields: Dict[SDocNodeField, None] = dict.fromkeys(
831+
other_requirement.ordered_fields_lookup.get("COMMENT", []), None
832832
)
833833

834834
if len(changed_fields) == 0 or len(changed_other_fields) == 0:
835-
for changed_field_ in changed_fields:
835+
for changed_field_ in changed_fields.keys():
836836
changes.append(
837837
RequirementFieldChange(
838838
field_name="COMMENT",
@@ -842,7 +842,7 @@ def create_comment_field_changes(
842842
right_diff=None,
843843
)
844844
)
845-
for changed_other_field_ in changed_other_fields:
845+
for changed_other_field_ in changed_other_fields.keys():
846846
changes.append(
847847
RequirementFieldChange(
848848
field_name="COMMENT",
@@ -864,8 +864,8 @@ def create_comment_field_changes(
864864

865865
similarity = similar(comment_value, comment_other_value)
866866
if similarity == 1:
867-
changed_fields.remove(changed_field_)
868-
changed_other_fields.remove(changed_other_field_)
867+
del changed_fields[changed_field_]
868+
del changed_other_fields[changed_other_field_]
869869
break
870870

871871
similarities.append(
@@ -905,8 +905,8 @@ def create_comment_field_changes(
905905
right_diff=right_diff,
906906
)
907907
)
908-
changed_fields.remove(changed_field_)
909-
changed_other_fields.remove(changed_other_field_)
908+
del changed_fields[changed_field_]
909+
del changed_other_fields[changed_other_field_]
910910

911911
# Iterate over remaining fields.
912912
for changed_field_ in changed_fields:

0 commit comments

Comments
 (0)