Add pre-commit-config, isort, flake8, black

This commit is contained in:
thatdonfc 2020-12-18 14:28:10 -08:00
parent 30f4aaa0f0
commit de5e220b82
No known key found for this signature in database
GPG Key ID: 805A5EDAE682FD3A
5 changed files with 51 additions and 17 deletions

View File

@ -38,7 +38,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install system dependencies
run: |
sudo apt-get install -y python3-dev portaudio19-dev libatlas3-base
@ -46,7 +46,7 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: '3.9'
# - name: Cache pip
# - name: Cache pip
# uses: actions/cache@v2
# env:
# cache-name: cache-pip
@ -55,16 +55,16 @@ jobs:
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/requirements.txt') }}
# restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}-
- name: Install python dependencies
run: |
- name: Install python dependencies
run: |
python -m pip install --upgrade pip wheel setuptools
pip install Cython
# pip install numpy==1.19.3
# if [ -f requirements.txt ];
# then pip install -r requirements.txt;
# fi
# # Set the `CODEQL-PYTHON` environment variable to the Python executable
# # that includes the dependencies
# if [ -f requirements.txt ];
# then pip install -r requirements.txt;
# fi
# # Set the `CODEQL-PYTHON` environment variable to the Python executable
# # that includes the dependencies
# echo "::set-env name=CODEQL_PYTHON::$(which python)"x'
- name: Lint with flake8
run: |
@ -76,7 +76,7 @@ jobs:
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# Override the default behavior so that the action doesn't attempt
# Override the default behavior so that the action doesn't attempt
# to auto-install Python dependencies
setup-python-dependencies: false
# If you wish to specify custom queries, you can do so here or in a config file.
@ -102,7 +102,7 @@ jobs:
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
analyze-javascript:
name: Analyze Javascript
runs-on: ubuntu-latest

26
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,26 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
hooks:
- id: check-yaml
- id: check-ast
- id: trailing-whitespace
- id: check-toml
- repo: https://github.com/PyCQA/isort
rev: 5.6.4
hooks:
- id: isort
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
- repo: https://github.com/psf/black
rev: 20.8b1 # Replace by any tag/version: https://github.com/psf/black/tags
hooks:
- id: black

View File

@ -1,10 +1,11 @@
[tool.black]
line-length = 89
line-length = 79
target-version = ["py37", "py38"]
[tool.isort]
profile = "black"
line_length = 89
line_length = 79
# The following are the default values applied when profile="black"
# multi_line_output = 3
# include_trailing_comma = True
# force_grid_wrap = 0

7
requirements-dev.txt Normal file
View File

@ -0,0 +1,7 @@
# Requirements. These can can be installed with:
# pip install -r requirements-dev.txt
flake8>=3.8.4
black>=20.8b1
isort>=5.6.4
pre-commit>=2.9.3

View File

@ -41,11 +41,10 @@ source_dir = docs/source
build_dir = docs/build
[flake8]
max-line-length = 89
max-line-length = 79
extend-ignore = E203, W503
ignore =
E501,
E203,
W503,
F601,
F811,
F841
@ -54,4 +53,5 @@ exclude =
build
dist
.eggs
docs/conf.py
docs/conf.py
node_modules