Skip to content

Commit d4cec2c

Browse files
authored
Merge pull request #2184 from strictdoc-project/stanislaw/remove_free_text
Code climate: sdoc_source_code/reader_c: rewrite some missing coverage code
2 parents f4af016 + bd8333d commit d4cec2c

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

strictdoc/backend/sdoc/models/inline_link.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# mypy: disable-error-code="no-untyped-call,no-untyped-def"
21
from typing import Any
32

43
from strictdoc.helpers.auto_described import auto_described

strictdoc/backend/sdoc_source_code/reader_c.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,9 @@ def read(
312312
function_name
313313
] = new_function
314314
elif node_.type == "comment":
315-
if node_.text is None:
316-
raise NotImplementedError("Comment without a text")
315+
assert node_.text is not None, (
316+
f"Comment without a text: {node_}"
317+
)
317318

318319
node_text_string = node_.text.decode("utf8")
319320

@@ -335,7 +336,7 @@ def read(
335336
):
336337
line_marker_processor(line_marker_, parse_context)
337338
else:
338-
continue
339+
pass
339340
else:
340341
pass
341342

strictdoc/backend/sdoc_source_code/reader_python.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,9 @@ def read(
216216
function_markers
217217
)
218218
elif node_.type == "comment":
219-
if node_.text is None:
220-
raise NotImplementedError("Comment without a text")
219+
assert node_.text is not None, (
220+
f"Comment without a text: {node_}"
221+
)
221222

222223
node_text_string = node_.text.decode("utf8")
223224

@@ -240,7 +241,7 @@ def read(
240241
):
241242
line_marker_processor(line_marker, parse_context)
242243
else:
243-
continue
244+
pass
244245
else:
245246
pass
246247

strictdoc/helpers/auto_described.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
# for simplicity.
44
__version__ = "0.0.1"
55

6+
from typing import Any, Optional
7+
68

79
# Maybe there is a better way to generate __str__ and __repr__.
810
# But for now, this solution works good enough:
911
# https://stackoverflow.com/a/33800620/598057
1012
# https://stackoverflow.com/a/24617244/598057
11-
def auto_described(cls=None, str_and_repr=True):
13+
def auto_described(cls: Optional[Any] = None, str_and_repr: bool = True):
1214
def configure_class(clz):
1315
def __str__(self):
1416
return auto_str(self)

tests/unit/strictdoc/backend/sdoc_source_code/readers/test_reader_c.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
from strictdoc.backend.sdoc_source_code.reader_c import (
99
SourceFileTraceabilityReader_C,
1010
)
11-
from strictdoc.backend.sdoc_source_code.reader_python import (
12-
SourceFileTraceabilityReader_Python,
13-
)
1411

1512
pytestmark = pytest.mark.skipif(
1613
sys.version_info < (3, 9), reason="Requires Python 3.9 or higher"
@@ -20,7 +17,7 @@
2017
def test_00_empty_file():
2118
input_string = b""""""
2219

23-
reader = SourceFileTraceabilityReader_Python()
20+
reader = SourceFileTraceabilityReader_C()
2421

2522
info = reader.read(input_string)
2623

0 commit comments

Comments
 (0)