Black config, pre-commit and GHA

This commit is contained in:
Martin Kristiansen 2023-07-21 10:14:31 -04:00
parent be00a837cc
commit 8b4af69d87
3 changed files with 73 additions and 3 deletions

27
.github/workflows/style-checks.yml vendored Normal file
View File

@ -0,0 +1,27 @@
name: Black # TODO: add isort and flake8 later
on:
pull_request: {}
push:
branches: master
tags: "*"
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies with pip
run: |
pip install --upgrade pip wheel
pip install .[test]
# - run: isort --check-only .
- run: black --check .
# - run: flake8

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

@ -0,0 +1,40 @@
# See https://pre-commit.com/ for usage and config
repos:
- repo: local
hooks:
- id: black
name: black
stages: [commit]
language: system
entry: black
types: [python]
# - id: isort
# name: isort
# stages: [commit]
# language: system
# entry: isort
# types: [python]
# - id: flake8
# name: flake8
# stages: [commit]
# language: system
# entry: flake8
# types: [python]
# - id: mypy
# name: mypy
# stages: [commit]
# language: system
# entry: mypy
# types: [python]
# require_serial: true
# - id: pytest-cov
# name: pytest
# stages: [commit]
# language: system
# entry: pytest --cov --cov-fail-under=90
# types: [python]
# pass_filenames: false

View File

@ -98,7 +98,7 @@ dependencies = [
"dev" = [
"pudb",
]
"test" = ["pytest>6.0.0", "pytest-cov"]
"test" = ["pytest>6.0.0", "pytest-cov", "black"]
"xformers" = [
"xformers~=0.0.19; sys_platform!='darwin'",
"triton; sys_platform=='linux'",
@ -176,5 +176,8 @@ directory = "coverage/html"
output = "coverage/index.xml"
#=== End: PyTest and Coverage
[flake8]
max-line-length = 120
[tool.flake8]
max-line-length = 100
[tool.black]
line-length = 100