diff --git a/.github/workflows/style-checks.yml b/.github/workflows/style-checks.yml new file mode 100644 index 0000000000..e082ef1c7f --- /dev/null +++ b/.github/workflows/style-checks.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..988bc2d992 --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 5cc6971df6..d171c062dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 \ No newline at end of file