diff --git a/.github/workflows/se-test.yml b/.github/workflows/se-test.yml index 245228fa..9676eb98 100644 --- a/.github/workflows/se-test.yml +++ b/.github/workflows/se-test.yml @@ -19,7 +19,7 @@ jobs: - name: Install pipx packages run: | pipx install . - pipx inject standardebooks pylint==2.17.3 pytest==7.3.1 mypy==1.2.0 types-requests==2.28.11.17 types-setuptools==67.7.0.0 types-Pillow==10.2.0.20240331 + pipx inject standardebooks pytest==8.2.2 pylint==3.2.2 mypy==1.10.0 types-requests==2.32.0.20240602 types-setuptools==70.0.0.20240524 types-Pillow==10.2.0.20240520 - name: Check type annotations with mypy run: $PIPX_HOME/venvs/standardebooks/bin/mypy - name: Check code with pylint diff --git a/README.md b/README.md index eda354eb..474bd6e1 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ We export `COLUMNS` because `se lint` needs to know the width of the terminal so Before we can use `pylint` or `mypy` on the toolset source, we have to inject them (and additional typings) into the venv `pipx` created for the `standardebooks` package: ```shell -pipx inject standardebooks pylint==2.17.3 mypy==1.2.0 types-requests==2.28.11.17 types-setuptools==67.7.0.0 types-Pillow==10.2.0.20240331 +pipx inject standardebooks pylint==3.2.2 mypy==1.10.0 types-requests==2.32.0.20240602 types-setuptools==70.0.0.20240524 types-Pillow==10.2.0.20240520 ``` Then make sure to call the `pylint` and `mypy` binaries that `pipx` installed in the `standardebooks` venv, *not* any other globally-installed binaries: diff --git a/pylintrc b/pylintrc index 5c07342d..769c3557 100644 --- a/pylintrc +++ b/pylintrc @@ -6,7 +6,7 @@ ignore=vendor extension-pkg-whitelist=lxml,math,unicodedata [MESSAGES CONTROL] -disable=line-too-long,too-many-nested-blocks,too-many-branches,too-many-statements,too-many-boolean-expressions,too-many-lines,too-many-locals,broad-except,bare-except,too-few-public-methods,too-many-arguments,too-many-instance-attributes,too-many-public-methods,duplicate-code,no-member +disable=line-too-long,too-many-nested-blocks,too-many-branches,too-many-statements,too-many-boolean-expressions,too-many-lines,too-many-locals,broad-except,too-few-public-methods,too-many-arguments,too-many-instance-attributes,too-many-public-methods,duplicate-code,deprecated-method [FORMAT] indent-string=\t diff --git a/se/commands/interactive_replace.py b/se/commands/interactive_replace.py index eaf113f0..f54039aa 100644 --- a/se/commands/interactive_replace.py +++ b/se/commands/interactive_replace.py @@ -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) diff --git a/se/commands/word_count.py b/se/commands/word_count.py index 78dd6335..233c92b9 100644 --- a/se/commands/word_count.py +++ b/se/commands/word_count.py @@ -75,6 +75,8 @@ 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: @@ -82,6 +84,6 @@ def word_count(plain_output: bool) -> int: 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 diff --git a/se/se_epub.py b/se/se_epub.py index 6e95bab3..06857dce 100644 --- a/se/se_epub.py +++ b/se/se_epub.py @@ -1328,7 +1328,7 @@ def _check_endnotes(self) -> list: anchor = href[hash_position:] references.append(anchor) # keep these for later reverse check # Now try to find anchor in endnotes - matches = list(filter(lambda x, old=anchor: x.anchor == old, self.endnotes)) # type: ignore [arg-type] + matches = list(filter(lambda x, old=anchor: x.anchor == old, self.endnotes)) # type: ignore [arg-type, var-annotated] if not matches: missing.append(anchor) if len(matches) > 1: @@ -1521,7 +1521,7 @@ def __process_noteref_link(self, change_list, current_note_number, file_name, li link.lxml_element.text = str(current_note_number) needs_rewrite = True # Now try to find this in endnotes - matches = list(filter(lambda x, old=old_anchor: x.anchor == old, self.endnotes)) # type: ignore [arg-type] + matches = list(filter(lambda x, old=old_anchor: x.anchor == old, self.endnotes)) # type: ignore [arg-type, var-annotated] if not matches: raise se.InvalidInputException(f"Couldn’t find endnote with anchor [attr]{old_anchor}[/].") if len(matches) > 1: diff --git a/se/se_epub_lint.py b/se/se_epub_lint.py index 0ecdc42f..53738a6f 100644 --- a/se/se_epub_lint.py +++ b/se/se_epub_lint.py @@ -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 @@ -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) diff --git a/tests/README.md b/tests/README.md index a285d914..6d1496e5 100644 --- a/tests/README.md +++ b/tests/README.md @@ -3,7 +3,7 @@ Similar to `pylint`, the `pytest` command can be injected into the venv `pipx` created for the `standardebooks` package: ```shell -pipx inject standardebooks pytest==7.3.1 +pipx inject standardebooks pytest==8.2.2 ``` The tests are executed by calling `pytest` from the top level of your tools repo: