diff --git a/.editorconfig b/.editorconfig index 86578f1d..125c8178 100644 --- a/.editorconfig +++ b/.editorconfig @@ -17,5 +17,5 @@ trim_trailing_whitespace = false [*.{yaml,yml,py,md}] indent_style = space -[{.gitlab-ci.yml,*.md,.github/workflows/*.yml}] +[{.gitlab-ci.yml,*.md,.github/workflows/*.yml,.pre-commit-config.yaml}] indent_size = 2 diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index b490dfd8..5377dd4b 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -16,3 +16,10 @@ jobs: - uses: psf/black@21.12b0 with: src: "./mausignald ./mautrix_signal" + - name: pre-commit + run: | + pip install pre-commit + pre-commit run -av trailing-whitespace + pre-commit run -av end-of-file-fixer + pre-commit run -av check-yaml + pre-commit run -av check-added-large-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..c9d7e497 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,23 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: trailing-whitespace + exclude_types: [markdown] + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + # TODO convert to use the upstream psf/black when + # https://github.com/psf/black/issues/2493 gets fixed + - repo: local + hooks: + - id: black + name: black + entry: black --check + language: system + files: ^(mausignald|mautrix_signal)/.*\.py$ + - repo: https://github.com/PyCQA/isort + rev: 5.10.1 + hooks: + - id: isort + files: ^(mausignald|mautrix_signal)/.*$ diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 00000000..d337c3b8 --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1,3 @@ +pre-commit>=2.10.1,<3 +isort>=5.10.1,<6 +black==21.12b2 diff --git a/mausignald/LICENSE b/mausignald/LICENSE index 52d13511..a612ad98 100644 --- a/mausignald/LICENSE +++ b/mausignald/LICENSE @@ -35,7 +35,7 @@ Mozilla Public License Version 2.0 means any form of the work other than Source Code Form. 1.7. "Larger Work" - means a work that combines Covered Software with other material, in + means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. 1.8. "License" @@ -371,4 +371,3 @@ Exhibit B - "Incompatible With Secondary Licenses" Notice This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0. -