From f664d4ad904db36cbced56d37b9293e7adb4a2c4 Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Fri, 21 Jan 2022 00:02:42 -0700 Subject: [PATCH 1/3] pre-commit: add configuration --- .editorconfig | 2 +- .pre-commit-config.yaml | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .pre-commit-config.yaml diff --git a/.editorconfig b/.editorconfig index 96c9834e..10c7c30f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -17,5 +17,5 @@ max_line_length = 99 [*.{yaml,yml,py}] indent_style = space -[.gitlab-ci.yml] +[{.gitlab-ci.yml,.pre-commit-config.yaml}] indent_size = 2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..0149638a --- /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: ^mautrix_telegram/.*\.py$ + - repo: https://github.com/PyCQA/isort + rev: 5.10.1 + hooks: + - id: isort + files: ^mautrix_telegram/.*$ From 984c52afc92eba6b12c5cf913b9f40748e1e6679 Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Fri, 21 Jan 2022 11:15:21 -0700 Subject: [PATCH 2/3] dev-requirements: add pre-commit, isort, black --- dev-requirements.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 dev-requirements.txt 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 From 7c4f406ac6cf19a9c4db8a6862b3895f5ba43f3c Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Fri, 21 Jan 2022 11:15:52 -0700 Subject: [PATCH 3/3] ci: add pre-commit-hooks to lint process --- .github/workflows/python-lint.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index ef4ab384..9aec0238 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: "./mautrix_telegram" + - 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