Skip to content

Commit

Permalink
Get pylint passing at 100%
Browse files Browse the repository at this point in the history
- a couple of branch removals
- a couple of potentially unintialised variables
  • Loading branch information
robinwhittleton committed Jun 6, 2024
1 parent e7a5a6c commit 858a25a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 1 addition & 2 deletions se/commands/interactive_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ def _get_text_dimensions(text: str) -> Tuple[int, int]:
else:
line_length = line_length + 1

if line_length > text_width:
text_width = line_length
text_width = max(text_width, line_length)

return (text_height + 1, text_width + 1)

Expand Down
4 changes: 3 additions & 1 deletion se/commands/word_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ def word_count(plain_output: bool) -> int:
se.print_error(f"Couldn’t open file: [path][link=file://{filename}]{filename}[/][/].", plain_output=plain_output)
return se.InvalidInputException.code

category = ""

if args.categorize:
category = "se:short-story"
if NOVELLA_MIN_WORD_COUNT <= total_word_count < NOVEL_MIN_WORD_COUNT:
category = "se:novella"
elif total_word_count >= NOVEL_MIN_WORD_COUNT:
category = "se:novel"

print(f"{total_word_count}\t{category if args.categorize else ''}")
print(f"{total_word_count}\t{category}")

return 0
4 changes: 2 additions & 2 deletions se/se_epub_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,7 @@ def __init__(self, code: str, text: str, message_type=se.MESSAGE_TYPE_WARNING, f
for submessage in submessages:
# Try to flatten leading indentation
for indent in regex.findall(r"^\t+(?=<)", submessage, flags=regex.MULTILINE):
if len(indent) < smallest_indent:
smallest_indent = len(indent)
smallest_indent = min(smallest_indent, len(indent))

if smallest_indent == 1000:
smallest_indent = 0
Expand Down Expand Up @@ -1505,6 +1504,7 @@ def _lint_special_file_checks(self, filename: Path, dom: se.easy_xml.EasyXmlTree
for node in dom.xpath("/html/body/nav[contains(@epub:type, 'loi')]//li//a"):
figure_ref = node.get_attr("href").split("#")[1]
chapter_ref = regex.findall(r"(.*?)#.*", node.get_attr("href"))[0]
figure_img_alt = ""
figcaption_text = ""
loi_text = node.inner_text()
file_dom = self.get_dom(self.content_path / "text" / chapter_ref)
Expand Down

0 comments on commit 858a25a

Please sign in to comment.