Skip to content

Commit af331f7

Browse files
committed
Fixed static typing errors and formatting
1 parent e5eb52d commit af331f7

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/lazydocs/generation.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ class SectionBlock():
410410
indent: int
411411
offset: int
412412

413-
def _get_section_offset(lines: list, start_index: int, blockindent: int):
413+
def _get_section_offset(lines: list, start_index: int, blockindent: int) -> int:
414414
"""Determine base padding offset for section.
415415
416416
Args:
@@ -421,7 +421,7 @@ def _get_section_offset(lines: list, start_index: int, blockindent: int):
421421
Returns:
422422
int: Padding offset.
423423
"""
424-
offset = []
424+
offset: List[int] = []
425425
try:
426426
for line in lines[start_index:]:
427427
indent = len(line) - len(line.lstrip())
@@ -436,9 +436,9 @@ def _get_section_offset(lines: list, start_index: int, blockindent: int):
436436
return -min(offset) if offset else 0
437437

438438
def _lines_isvalid(lines: list, start_index: int, blockindent: int,
439-
allow_same_level: bool = False,
440-
require_next_is_blank: bool = False,
441-
max_blank: int = None):
439+
allow_same_level: bool = False,
440+
require_next_is_blank: bool = False,
441+
max_blank: Optional[int] = None) -> bool:
442442
"""Determine following lines fit section rules.
443443
444444
Args:
@@ -517,11 +517,11 @@ def _lines_isvalid(lines: list, start_index: int, blockindent: int,
517517
line = line + "\n```"
518518
elif doctest_block and \
519519
not _lines_isvalid(docstring, line_indx + 1, doctest_block.indent,
520-
True, False, 1):
520+
True, False, 1):
521521
# Doctest block Exit Condition
522522
offset = doctest_block.indent - indent
523-
line = " " * (indent - doctest_block.indent +
524-
doctest_block.offset) + line + "\n```"
523+
line = " " * (indent - doctest_block.indent
524+
+ doctest_block.offset) + line + "\n```"
525525
block_exit = True
526526
elif line.endswith("::") and not (literal_block) and \
527527
_lines_isvalid(docstring, line_indx + 1, indent, False, True, None):
@@ -538,11 +538,11 @@ def _lines_isvalid(lines: list, start_index: int, blockindent: int,
538538
line = "```" + line
539539
indent = literal_block.indent
540540
elif not _lines_isvalid(docstring, line_indx + 1, literal_block.indent,
541-
False, False, None):
541+
False, False, None):
542542
# Literal block exit condition
543543
offset += literal_block.indent - indent
544-
line = " " * (indent - literal_block.indent +
545-
literal_block.offset) + line + "\n```"
544+
line = " " * (indent - literal_block.indent
545+
+ literal_block.offset) + line + "\n```"
546546
block_exit = True
547547
elif line:
548548
offset += literal_block.offset
@@ -561,7 +561,7 @@ def _lines_isvalid(lines: list, start_index: int, blockindent: int,
561561
offset = admonition_block.indent - indent
562562
line = "> {}".format(line.replace("\n", "\n> "))
563563
if not _lines_isvalid(docstring, line_indx + 1, admonition_block.indent,
564-
False, False, None):
564+
False, False, None):
565565
admonition_block = None
566566

567567
if (blockstart_result or blocktext_result):
@@ -630,6 +630,7 @@ def _lines_isvalid(lines: list, start_index: int, blockindent: int,
630630
prev_blank_line_count += 1
631631
return "".join(out)
632632

633+
633634
class MarkdownGenerator(object):
634635
"""Markdown generator class."""
635636

@@ -1406,5 +1407,5 @@ def generate_docs(
14061407
# Write mkdocs pages file
14071408
print("Writing mkdocs .pages file.")
14081409
# TODO: generate navigation items to fix problem with naming
1409-
with open(os.path.join(output_path, ".pages"), "w", encoding="utf-8", newline="\n") as f:
1410+
with open(os.path.join(output_path, ".pages"), "w", encoding="utf-8", newline="\n") as f:
14101411
f.write(_MKDOCS_PAGES_TEMPLATE.format(overview_file=overview_file))

0 commit comments

Comments
 (0)