Эх сурвалжийг харах

Merge pull request #200 from mautrix/pre-commit-config

pre-commit: add configuration
Sumner Evans 3 жил өмнө
parent
commit
6cb9685d86

+ 1 - 1
.editorconfig

@@ -17,5 +17,5 @@ trim_trailing_whitespace = false
 [*.{yaml,yml,py,md}]
 [*.{yaml,yml,py,md}]
 indent_style = space
 indent_style = space
 
 
-[{.gitlab-ci.yml,*.md,.github/workflows/*.yml}]
+[{.gitlab-ci.yml,*.md,.github/workflows/*.yml,.pre-commit-config.yaml}]
 indent_size = 2
 indent_size = 2

+ 7 - 0
.github/workflows/python-lint.yml

@@ -16,3 +16,10 @@ jobs:
     - uses: psf/black@21.12b0
     - uses: psf/black@21.12b0
       with:
       with:
         src: "./mausignald ./mautrix_signal"
         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

+ 23 - 0
.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)/.*$

+ 3 - 0
dev-requirements.txt

@@ -0,0 +1,3 @@
+pre-commit>=2.10.1,<3
+isort>=5.10.1,<6
+black==21.12b2

+ 1 - 2
mausignald/LICENSE

@@ -35,7 +35,7 @@ Mozilla Public License Version 2.0
     means any form of the work other than Source Code Form.
     means any form of the work other than Source Code Form.
 
 
 1.7. "Larger Work"
 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.
     a separate file or files, that is not Covered Software.
 
 
 1.8. "License"
 1.8. "License"
@@ -371,4 +371,3 @@ Exhibit B - "Incompatible With Secondary Licenses" Notice
 
 
   This Source Code Form is "Incompatible With Secondary Licenses", as
   This Source Code Form is "Incompatible With Secondary Licenses", as
   defined by the Mozilla Public License, v. 2.0.
   defined by the Mozilla Public License, v. 2.0.
-