From d4d0aaf83b54880a7579c58cf571e359f6067f45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vjeran=20Grozdani=C4=87?= Date: Mon, 13 Jan 2025 21:43:13 +0100 Subject: [PATCH] Add ruff linter and formatter to pre-commit (#856) * Add ruff linter to pre-commit * add ruff formater too * ruff format all files * formatting --- .pre-commit-config.yaml | 20 ++++++++++---------- setup.py | 7 ++++--- tests/test_backends.py | 3 +-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 20a21a34f..10d75fcf2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,20 +3,20 @@ repos: rev: 'v4.5.0' hooks: - id: check-merge-conflict +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.9.1 + hooks: + - id: ruff + types_or: [ python, pyi ] + args: [--select, I, --fix,] + files: "^tests/|^rest_framework_simplejwt/" + - id: ruff-format + types_or: [python, pyi] + files: "^tests/|^rest_framework_simplejwt/" - repo: https://github.com/asottile/yesqa rev: v1.5.0 hooks: - id: yesqa -- repo: https://github.com/pycqa/isort - rev: '5.12.0' - hooks: - - id: isort - args: ["--profile", "black"] -- repo: https://github.com/psf/black - rev: '23.11.0' - hooks: - - id: black - language_version: python3 # Should be a command that runs python3.6+ - repo: https://github.com/pre-commit/pre-commit-hooks rev: 'v4.5.0' hooks: diff --git a/setup.py b/setup.py index a72e0b3b5..aa08d5295 100755 --- a/setup.py +++ b/setup.py @@ -14,9 +14,10 @@ "tox", ], "lint": [ - "flake8", - "pep8", - "isort", + "ruff", + "yesqa", + "pyupgrade", + "pre-commit", ], "doc": [ "Sphinx>=1.6.5,<2", diff --git a/tests/test_backends.py b/tests/test_backends.py index 47b22228d..0d7cce944 100644 --- a/tests/test_backends.py +++ b/tests/test_backends.py @@ -9,9 +9,8 @@ import jwt import pytest from django.test import TestCase -from jwt import PyJWS +from jwt import PyJWS, algorithms from jwt import __version__ as jwt_version -from jwt import algorithms from rest_framework_simplejwt.backends import JWK_CLIENT_AVAILABLE, TokenBackend from rest_framework_simplejwt.exceptions import (