From 2d5551b80d15a3bd080c8bffab85eb52f719f7bb Mon Sep 17 00:00:00 2001 From: truePhilipp Date: Thu, 2 May 2024 18:37:03 +0200 Subject: [PATCH] added stylecheck job to github action --- .github/workflows/main.yml | 17 +++++++++++++++++ html_to_django/formatters/if_formatter.py | 2 +- html_to_django/main.py | 7 +++---- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4e3cb8a..d9f4ad9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,6 +3,23 @@ name: Python package on: [push] jobs: + stylecheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: Install Dependencies + run: | + pip install ".[test]" + mypy src || true + mypy --install-types --non-interactive + - name: Stylecheck + run: | + mypy --strict src + pycodestyle --max-line-length 120 src test: runs-on: ubuntu-latest strategy: diff --git a/html_to_django/formatters/if_formatter.py b/html_to_django/formatters/if_formatter.py index c48493e..5d1c7d9 100644 --- a/html_to_django/formatters/if_formatter.py +++ b/html_to_django/formatters/if_formatter.py @@ -19,7 +19,7 @@ def format(soup: BeautifulSoup) -> None: current_sibling = None else: current_sibling = None - + participating_blocks[-1].insert_after("{% endif %}") for block in participating_blocks: diff --git a/html_to_django/main.py b/html_to_django/main.py index 3aebe5a..8c29664 100644 --- a/html_to_django/main.py +++ b/html_to_django/main.py @@ -2,18 +2,17 @@ import bs4 from .formatters import formatters -def main(): +def main() -> None: with open("test.html", "r") as file: soup = bs4.BeautifulSoup(file, "html.parser") for formatter in formatters: formatter.format(soup) - formatter = bs4.formatter.HTMLFormatter(indent=4) with open("out.html", "w") as file: file.write("{% load static %}\n") - file.write(soup.prettify(formatter=formatter)) + file.write(soup.prettify(formatter=bs4.formatter.HTMLFormatter(indent=4))) -def command_entry(): +def command_entry() -> None: print("ok")