diff --git a/.github/workflows/black.yml b/.github/workflows/formatting.yml similarity index 69% rename from .github/workflows/black.yml rename to .github/workflows/formatting.yml index 60949c58..9dfedc7e 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/formatting.yml @@ -1,4 +1,4 @@ -name: "Black" +name: "Formatting" on: [push] jobs: @@ -8,6 +8,7 @@ jobs: matrix: python-version: ["3.12"] os: [ubuntu-latest] + tool: ["black", "isort"] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} @@ -17,7 +18,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install black - - name: Black Code Formatter + pip install -r dev_requirements/requirements-formatting.txt + - name: ${{ matrix.tool }} Code Formatter run: | - black . --check + ${{ matrix.tool }} . --check diff --git a/dev_requirements/requirements-formatting.in b/dev_requirements/requirements-formatting.in new file mode 100644 index 00000000..98a546c7 --- /dev/null +++ b/dev_requirements/requirements-formatting.in @@ -0,0 +1,3 @@ +# specific requirements for the tox formatting environment +black +isort diff --git a/dev_requirements/requirements-formatting.txt b/dev_requirements/requirements-formatting.txt new file mode 100644 index 00000000..a86e08d8 --- /dev/null +++ b/dev_requirements/requirements-formatting.txt @@ -0,0 +1,22 @@ +# +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: +# +# pip-compile requirements-formatting.in +# +black==24.1.1 + # via -r requirements-formatting.in +click==8.1.7 + # via black +colorama==0.4.6 + # via click +isort==5.12.0 + # via -r requirements-formatting.in +mypy-extensions==1.0.0 + # via black +packaging==23.2 + # via black +pathspec==0.12.1 + # via black +platformdirs==4.1.0 + # via black diff --git a/src/kohlrahbi/__init__.py b/src/kohlrahbi/__init__.py index 7afcdd85..66ca42dd 100644 --- a/src/kohlrahbi/__init__.py +++ b/src/kohlrahbi/__init__.py @@ -1,6 +1,7 @@ """ kohlrahbi is a package to scrape AHBs (in docx format) """ + import fnmatch import gc import json diff --git a/src/kohlrahbi/ahb/ahbtable.py b/src/kohlrahbi/ahb/ahbtable.py index c3b0e24e..fde90b7a 100644 --- a/src/kohlrahbi/ahb/ahbtable.py +++ b/src/kohlrahbi/ahb/ahbtable.py @@ -1,6 +1,7 @@ """ This module provides the AhbTable class """ + from pathlib import Path from typing import Union diff --git a/src/kohlrahbi/ahb/ahbtablerow.py b/src/kohlrahbi/ahb/ahbtablerow.py index 0c43a394..66f90ea3 100644 --- a/src/kohlrahbi/ahb/ahbtablerow.py +++ b/src/kohlrahbi/ahb/ahbtablerow.py @@ -1,6 +1,7 @@ """ This module contains the class AhbTableRow """ + from typing import Optional import pandas as pd diff --git a/src/kohlrahbi/changehistory/changehistorytable.py b/src/kohlrahbi/changehistory/changehistorytable.py index 6a25f59b..cb89d41e 100644 --- a/src/kohlrahbi/changehistory/changehistorytable.py +++ b/src/kohlrahbi/changehistory/changehistorytable.py @@ -1,6 +1,7 @@ """ This module provides the ChangeHistoryTable class """ + import attrs import pandas as pd from docx.table import Table # type:ignore[import] diff --git a/src/kohlrahbi/collect_pruefis.py b/src/kohlrahbi/collect_pruefis.py index afece63b..42f6fb7e 100644 --- a/src/kohlrahbi/collect_pruefis.py +++ b/src/kohlrahbi/collect_pruefis.py @@ -4,6 +4,7 @@ Use this script to create an updated version of the all_known_pruefis.toml file. You should run it every time there is an update at edi-energy.de. """ + from datetime import date from pathlib import Path diff --git a/src/kohlrahbi/docxfilefinder.py b/src/kohlrahbi/docxfilefinder.py index 2706f7e2..082e90c8 100644 --- a/src/kohlrahbi/docxfilefinder.py +++ b/src/kohlrahbi/docxfilefinder.py @@ -1,6 +1,7 @@ """ This module contains the DocxFileFinder class. """ + from itertools import groupby from pathlib import Path diff --git a/src/kohlrahbi/docxtablecells/bodycell.py b/src/kohlrahbi/docxtablecells/bodycell.py index 866fa247..df8677a4 100644 --- a/src/kohlrahbi/docxtablecells/bodycell.py +++ b/src/kohlrahbi/docxtablecells/bodycell.py @@ -1,6 +1,7 @@ """ This module contains the class BodyCell """ + import attrs import pandas as pd from docx.table import _Cell # type:ignore[import] diff --git a/src/kohlrahbi/docxtablecells/edifactstrukturcell.py b/src/kohlrahbi/docxtablecells/edifactstrukturcell.py index ad0eedab..f90c3f98 100644 --- a/src/kohlrahbi/docxtablecells/edifactstrukturcell.py +++ b/src/kohlrahbi/docxtablecells/edifactstrukturcell.py @@ -1,6 +1,7 @@ """ This module contains the class EdifactStrukturCell """ + import re import attrs diff --git a/src/kohlrahbi/logger.py b/src/kohlrahbi/logger.py index d1282b8b..a8c915c8 100644 --- a/src/kohlrahbi/logger.py +++ b/src/kohlrahbi/logger.py @@ -1,6 +1,7 @@ """ This module provides a logger instance for kohlrahbi """ + import logging.config from pathlib import Path diff --git a/src/kohlrahbi/read_functions.py b/src/kohlrahbi/read_functions.py index a8160e95..bfa1942e 100644 --- a/src/kohlrahbi/read_functions.py +++ b/src/kohlrahbi/read_functions.py @@ -1,6 +1,7 @@ """ A collection of functions to get information from AHB tables. """ + import re from datetime import datetime from typing import Generator, Optional, Union diff --git a/src/kohlrahbi/row_type_checker.py b/src/kohlrahbi/row_type_checker.py index d9e6de12..ef817dd9 100644 --- a/src/kohlrahbi/row_type_checker.py +++ b/src/kohlrahbi/row_type_checker.py @@ -1,6 +1,7 @@ """ This module contains all functions to define the type of a row of the tables in an AHB. """ + from docx.oxml.ns import qn # type:ignore[import] from docx.oxml.parser import OxmlElement # type:ignore[import] from docx.shared import RGBColor # type:ignore[import] diff --git a/src/kohlrahbi/unfoldedahb/unfoldedahbtable.py b/src/kohlrahbi/unfoldedahb/unfoldedahbtable.py index 05d24aef..70963435 100644 --- a/src/kohlrahbi/unfoldedahb/unfoldedahbtable.py +++ b/src/kohlrahbi/unfoldedahb/unfoldedahbtable.py @@ -1,6 +1,7 @@ """ This module contains the UnfoldedAhbTable class. """ + import copy import json import re diff --git a/tox.ini b/tox.ini index 91026147..56fbd360 100644 --- a/tox.ini +++ b/tox.ini @@ -59,8 +59,7 @@ deps = {[testenv:tests]deps} {[testenv:linting]deps} {[testenv:coverage]deps} - black - isort + -r dev_requirements/requirements-formatting.txt pip-tools pre-commit commands = diff --git a/unittests/test_docx_extensions.py b/unittests/test_docx_extensions.py index 627d6e62..a643dead 100644 --- a/unittests/test_docx_extensions.py +++ b/unittests/test_docx_extensions.py @@ -1,6 +1,7 @@ """ tests all the features the kohlrahbi package provides to process Docx files (by using the docx package) """ + import pytest # type:ignore[import] from _pytest.fixtures import SubRequest # type:ignore[import] from docx import Document # type:ignore[import]