diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000000..b024411da3 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,23 @@ +name: Python check + +on: + push: + branches: + - develop + pull_request: + + +jobs: + pre_commit_checks: + name: 🚴 Pre-Commit checks 🚴 + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@main + - name: Install poetry + run: pipx install poetry + - uses: actions/setup-python@main + with: + cache: 'poetry' + - run: poetry install + - uses: pre-commit/action@main diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..ac2e9099e1 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,31 @@ +default_language_version: + python: python3 + +# NOTE: Update in .flake8 pyproject.toml as well +exclude: | + (?x)^( + \.git| + __pycache__| + .*snap_test_.*\.py| + .+\/.+\/migrations\/.*| + legacy| + \.venv + ) + +repos: + - repo: https://github.com/psf/black + rev: 24.3.0 + hooks: + - id: black + # args: ["--check"] + + - repo: https://github.com/PyCQA/isort + rev: 5.13.2 + hooks: + - id: isort + # args: ["--check"] + + - repo: https://github.com/PyCQA/flake8 + rev: 7.0.0 + hooks: + - id: flake8 diff --git a/pyproject.toml b/pyproject.toml index 942456e5ec..f725d0d6c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -111,7 +111,7 @@ reportMissingImports = true reportMissingTypeStubs = false [tool.black] -line-length = 125 +line-length = 130 py36 = true include = '\.pyi?$' exclude = ''' @@ -126,7 +126,20 @@ exclude = ''' | docs )/ ''' -extend-exclude = '^.*\b(migrations)\b.*$' +# NOTE: Update in .pre-commit-config.yaml as well +extend-exclude = "^.*\\b(migrations)\\b.*$ (__pycache__|.*snap_test_.*\\.py|.+/+.+/+migrations/+.*)" + +[tool.isort] +profile = "black" +multi_line_output = 3 +# NOTE: Update in .pre-commit-config.yaml as well +skip = [ + "**/__pycache__", + "**/snap_test_*.py", + ".venv/", + "legacy/", + "**/migrations/*.py", +] [build-system] requires = ["poetry-core>=1.0.0"]