diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 37c4d8ec2..456d2672f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -51,6 +51,23 @@ repos: # - id: sort-simple-yaml - id: trailing-whitespace + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.33.0 + hooks: + - id: markdownlint + args: ["--disable", "MD013"] + + # - repo: https://github.com/markdownlint/markdownlint + # rev: v0.12.0 + # hooks: + # - id: markdownlint + + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: "v0.0.257" + hooks: + - id: ruff + args: [--fix, --exit-non-zero-on-fix] + - repo: https://github.com/asottile/add-trailing-comma rev: v2.4.0 hooks: @@ -141,16 +158,5 @@ repos: # hooks: # - id: codespell - - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.33.0 - hooks: - - id: markdownlint - args: ["--disable", "MD013"] - - # - repo: https://github.com/markdownlint/markdownlint - # rev: v0.12.0 - # hooks: - # - id: markdownlint - default_language_version: python: python3.10 diff --git a/chapters/translations/1_download.py b/chapters/translations/1_download.py index a3c8d9426..4ad07ed01 100755 --- a/chapters/translations/1_download.py +++ b/chapters/translations/1_download.py @@ -24,7 +24,7 @@ def download_file(url: str, filepath: str): Download file from url to filepath. """ headers = { - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0 ", + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0 ", # noqa: E501 } cont = requests.get(url, headers=headers, verify=True, timeout=3).content # verify=False -> skip SSL cert verification: CERTIFICATE_VERIFY_FAILED @@ -32,7 +32,7 @@ def download_file(url: str, filepath: str): fh.write(cont) -def download_all_chapters(): +def download_all_chapters() -> None: """ Download all chapters. diff --git a/chapters/translations/3_clean.py b/chapters/translations/3_clean.py index 3df2dd062..f78c6232b 100755 --- a/chapters/translations/3_clean.py +++ b/chapters/translations/3_clean.py @@ -37,11 +37,6 @@ def html_modify(): for translator in translators: print("===" + translator + "===") - # fhAll = open( - # f"4-join/hpmor-{translator}.html", mode="w", encoding="utf-8", newline="\n" - # ) - # fhAll.write(html_start) - for fileIn in sorted(glob.glob(f"2-extract/{translator}/*.html")): (filePath, fileName) = os.path.split(fileIn) fileOut = f"3-clean/{translator}/{fileName}" @@ -74,10 +69,6 @@ def html_modify(): fh.write(html_start) fh.write(out) fh.write(html_end) - # fhAll.write(out) - # break - # fhAll.write(html_end) - # fhAll.close() def html_tuning(s: str) -> str: diff --git a/scripts/check_chapters.py b/scripts/check_chapters.py index 630430d9e..bd6aed88c 100755 --- a/scripts/check_chapters.py +++ b/scripts/check_chapters.py @@ -131,7 +131,7 @@ def process_file(file_in: Path) -> bool: encoding="utf-8", ) as file2: diff = difflib.ndiff(file1.readlines(), file2.readlines()) - delta = "".join(l for l in diff if l.startswith("+ ") or l.startswith("- ")) + delta = "".join(x for x in diff if x.startswith("+ ") or x.startswith("- ")) print(file_in.name + "\n" + delta) return issues_found diff --git a/scripts/compare-translations.py b/scripts/compare-translations.py index 24b328c36..c0d34bab0 100755 --- a/scripts/compare-translations.py +++ b/scripts/compare-translations.py @@ -59,7 +59,7 @@ def download_file(url: str, filepath: str): Download file from url to filepath. """ headers = { - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0 ", + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0 ", # noqa: E501 } cont = requests.get(url, headers=headers, verify=True, timeout=3).content # verify=False -> skip SSL cert verification: CERTIFICATE_VERIFY_FAILED @@ -69,7 +69,7 @@ def download_file(url: str, filepath: str): # TODO: FR uses master as branch name def download_all_chapters(): - baseurl = "https://raw.githubusercontent.com/<>/main/chapters/hpmor-chapter-<>.tex" + baseurl = "https://raw.githubusercontent.com/<>/main/chapters/hpmor-chapter-<>.tex" # noqa: E501 # for lang in translations.keys(): lang = other_lang diff --git a/scripts/ebook/6.py b/scripts/ebook/6.py index ba824613d..3f7beb4fb 100755 --- a/scripts/ebook/6.py +++ b/scripts/ebook/6.py @@ -38,7 +38,7 @@ # remove duplication of author name cont = re.sub( - r"""

Fanfiction.*?

Basierend auf der Harry Potter Reihe von J. K. Rowling.*?

""", + r"""

Fanfiction.*?

Basierend auf der Harry Potter Reihe von J. K. Rowling.*?

""", # noqa: E501 "

Fanfiction basierend auf der Harry Potter Reihe von J. K. Rowling

", cont, flags=re.DOTALL | re.IGNORECASE, diff --git a/scripts/ebook/v1/1_latex2html.py b/scripts/ebook/v1/1_latex2html.py index aeabead22..f5de32ee9 100755 --- a/scripts/ebook/v1/1_latex2html.py +++ b/scripts/ebook/v1/1_latex2html.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 # by Torben Menke https://entorb.net +# flake8: noqa """ Converter script.