Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ruff linter and formatter to pre-commit #856

Merged
merged 4 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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,]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ruff has imports sorting as a part of linter, not formatter, so we need --select I here to force imports sorting

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:
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
"tox",
],
"lint": [
"flake8",
"pep8",
"isort",
"ruff",
"yesqa",
"pyupgrade",
"pre-commit",
],
"doc": [
"Sphinx>=1.6.5,<2",
Expand Down
3 changes: 1 addition & 2 deletions tests/test_backends.py
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After adding ruff linter/formatter to pre-commit, this was auto formatted. I can separate this change into another PR before merging this, but since this is only one change, i have bundled it with this PR

Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Loading