Skip to content

Commit 6bef92f

Browse files
Fix type checking issues by adding type ignores in CLI, detector, and splitter modules
1 parent 86a8462 commit 6bef92f

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

src/epub_splitter/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def split(
117117
) as progress:
118118
progress.add_task("Analyzing EPUB and detecting chapters...", total=None)
119119
detector = EpubChapterDetector(
120-
strategy=strategy, sensitivity=sensitivity, toc_level=toc_level
120+
strategy=strategy, sensitivity=sensitivity, toc_level=toc_level # type: ignore[arg-type]
121121
)
122122
result = detector.detect(epub_file)
123123

@@ -149,7 +149,7 @@ def split(
149149
format_name = "PDFs" if output_format == "pdf" else "EPUBs"
150150
console.print(f"\n[cyan]Splitting into {result.chapter_count} {format_name}...[/cyan]")
151151

152-
splitter = EpubSplitter(output_dir, filename_pattern=pattern, output_format=output_format)
152+
splitter = EpubSplitter(output_dir, filename_pattern=pattern, output_format=output_format) # type: ignore
153153

154154
with Progress(console=console) as progress:
155155
progress_msg = f"[cyan]Creating chapter {format_name}..."
@@ -233,7 +233,7 @@ def preview(
233233
) as progress:
234234
progress.add_task("Analyzing EPUB and detecting chapters...", total=None)
235235
detector = EpubChapterDetector(
236-
strategy=strategy, sensitivity=sensitivity, toc_level=toc_level
236+
strategy=strategy, sensitivity=sensitivity, toc_level=toc_level # type: ignore[arg-type]
237237
)
238238
result = detector.detect(epub_file)
239239

src/epub_splitter/detector.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
from pathlib import Path
44
from typing import List, Literal, Tuple
5-
from lxml import html as lxml_html
6-
import ebooklib
7-
from ebooklib import epub
5+
from lxml import html as lxml_html # type: ignore
6+
import ebooklib # type: ignore
7+
from ebooklib import epub # type: ignore
88

99
from epub_splitter.models import EpubChapter, EpubDetectionResult
1010

@@ -175,7 +175,7 @@ def _parse_href(self, href: str) -> Tuple[str, str]:
175175
if "#" in href:
176176
file_path, html_id = href.split("#", 1)
177177
return file_path, html_id
178-
return href, None
178+
return href, ""
179179

180180
def _detect_from_structure(self, book: epub.EpubBook) -> List[EpubChapter]:
181181
"""
@@ -286,17 +286,17 @@ def _extract_title_from_content(self, item: epub.EpubItem) -> str:
286286
# Try title tag first
287287
title_elem = tree.find(".//title")
288288
if title_elem is not None and title_elem.text:
289-
return title_elem.text.strip()
289+
return title_elem.text.strip() # type: ignore[no-any-return]
290290

291291
# Try first h1
292292
h1 = tree.find(".//h1")
293293
if h1 is not None:
294-
return h1.text_content().strip()
294+
return h1.text_content().strip() # type: ignore[no-any-return]
295295

296296
# Try first h2
297297
h2 = tree.find(".//h2")
298298
if h2 is not None:
299-
return h2.text_content().strip()
299+
return h2.text_content().strip() # type: ignore[no-any-return]
300300

301301
except Exception:
302302
pass

src/epub_splitter/splitter.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import re
44
from pathlib import Path
55
from typing import List, Set, Literal
6-
from lxml import html as lxml_html
7-
from ebooklib import epub
6+
from lxml import html as lxml_html # type: ignore
7+
from ebooklib import epub # type: ignore
88
import fitz # PyMuPDF
99

1010
from epub_splitter.models import EpubChapter
@@ -220,7 +220,7 @@ def _html_to_pdf(
220220
y_position += line_height
221221

222222
# Add paragraph spacing
223-
y_position += line_height / 2
223+
y_position += int(line_height / 2)
224224

225225
# Set metadata
226226
if preserve_metadata:
@@ -326,14 +326,14 @@ def _extract_chapter_section(self, item: epub.EpubItem, html_id: str) -> bytes:
326326
body = new_tree.find(".//body")
327327
body.append(element)
328328

329-
return lxml_html.tostring(new_tree, encoding="utf-8")
329+
return lxml_html.tostring(new_tree, encoding="utf-8") # type: ignore[no-any-return]
330330

331331
# If ID not found, return original content
332-
return content
332+
return content # type: ignore[no-any-return]
333333

334334
except Exception:
335335
# If extraction fails, return original content
336-
return item.get_content()
336+
return item.get_content() # type: ignore[no-any-return]
337337

338338
def _find_referenced_resources(
339339
self,

0 commit comments

Comments
 (0)