Skip to content

Commit 52cad4f

Browse files
authored
Use pre-commit framework for linters & formatters (#464)
* Wrap ruff with pre-commit * Add django-upgrade pre-commit config * Add basic pre-commit hooks
1 parent 6294d0b commit 52cad4f

File tree

6 files changed

+32
-8
lines changed

6 files changed

+32
-8
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,3 @@ jobs:
5858
skip-existing: true
5959
verbose: true
6060
print-hash: true
61-

.pre-commit-config.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
repos:
2+
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v5.0.0
5+
hooks:
6+
- id: check-case-conflict
7+
- id: check-merge-conflict
8+
- id: check-yaml
9+
- id: end-of-file-fixer
10+
- id: trailing-whitespace
11+
12+
- repo: https://github.com/adamchainz/django-upgrade
13+
rev: "1.25.0"
14+
hooks:
15+
- id: django-upgrade
16+
args: [--target-version, "4.2"]
17+
18+
- repo: https://github.com/astral-sh/ruff-pre-commit
19+
rev: v0.11.13
20+
hooks:
21+
- id: ruff-check
22+
name: ruff check
23+
args: ["--fix"]
24+
- id: ruff-format
25+
name: ruff format

LICENSE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,3 @@
199199
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200200
See the License for the specific language governing permissions and
201201
limitations under the License.
202-

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
def get_version():
1010
version_file = open("django_prometheus/__init__.py").read()
1111
version_match = re.search(
12-
r'^__version__ = [\'"]([^\'"]*)[\'"]', version_file, re.MULTILINE
12+
r'^__version__ = [\'"]([^\'"]*)[\'"]',
13+
version_file,
14+
re.MULTILINE,
1315
)
1416
if version_match:
1517
return version_match.group(1)

tox.ini

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ commands =
3535

3636
[testenv:py39-lint]
3737
deps =
38-
ruff==0.11.13
38+
pre-commit==4.2.0
3939
commands =
40-
ruff format --check django_prometheus/
41-
ruff check django_prometheus/
40+
pre-commit run --all-files

update_version_from_git.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
git symbolic-ref -q --short HEAD || git describe --tags --exact-match
2222
"""
2323

24-
import io
2524
import re
2625
import subprocess
2726
import sys
@@ -125,5 +124,6 @@ def release_version_correct():
125124
else:
126125
print(
127126
"Invalid usage. Supply 0 or 1 arguments. "
128-
"Argument can be either a version '1.2.3' or 'patch' if you want to increase the patch-version (1.2.3 -> 1.2.4.dev)"
127+
"Argument can be either a version '1.2.3' or 'patch' "
128+
"if you want to increase the patch-version (1.2.3 -> 1.2.4.dev)"
129129
)

0 commit comments

Comments
 (0)