diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..208d99a --- /dev/null +++ b/.flake8 @@ -0,0 +1,20 @@ +[flake8] +max-line-length=110 +docstring-convention=all +import-order-style=pycharm +exclude=constants.py,__pycache__,.cache,.git,.md,.svg,.png,tests,venv,.venv + +ignore= + B311,W503,E226,S311,T000 + # Missing Docstrings + D100,D104,D105,D107, + # Docstring Whitespace + D203,D212,D214,D215, + # Docstring Quotes + D301,D302, + # Docstring Content + D400,D401,D402,D404,D405,D406,D407,D408,D409,D410,D411,D412,D413,D414,D416,D417 + # Type Annotations + ANN002,ANN003,ANN101,ANN102,ANN204,ANN206 + # Whitespace Before + E203 diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 0000000..4687d2e --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,51 @@ +name: Linting + +on: [push, pull_request] + +jobs: + lint: + + runs-on: ubuntu-latest + + env: + PIP_CACHE_DIR: /tmp/pip-cache-dir + + steps: + - name: Checks out repository + uses: actions/checkout@v2 + + - name: Set up Python 3.9 + id: python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + # This step caches our Python dependencies. To make sure we + # only restore a cache when the dependencies, the python version and + # the runner operating system we create a cache key + # that is a composite of those states. + # Only when the context is exactly the same, we will restore the cache. + - name: Restore pip cache + uses: actions/cache@v2 + with: + path: ${{ env.PIP_CACHE_DIR }} + key: "python-0-${{ runner.os }}-\ + ${{ steps.python.outputs.python-version }}-\ + ${{ hashFiles('./requirements.txt', './requirements-dev.txt') }}" + + - name: Install dependencies + run: | + pip install -r requirements.txt + pip install -r requirements-dev.txt + + # Run flake8 and have it format the linting errors in the format of + # the GitHub Workflow command to register error annotations. This + # means that our flake8 output is automatically added as an error + # annotation to both the run result and in the "Files" tab of a + # pull request. + # + # Format used: + # ::error file={filename},line={line},col={col}::{message} + - name: Run flake8 + run: "flake8 \ + --format='::error file=%(path)s,line=%(row)d,col=%(col)d::[flake8] %(code)s: %(text)s'" diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..056ff0d --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,9 @@ +flake8~=3.8.4 +flake8-annotations~=2.4.1 +flake8-bugbear~=20.1.4 +flake8-docstrings~=1.5.0 +flake8-import-order~=0.18.1 +flake8-string-format~=0.3.0 +flake8-tidy-imports~=4.1.0 +flake8-todo~=0.7 +pep8-naming~=0.11.1