Skip to content

Commit 28b3571

Browse files
authored
code linting with ruff (#29)
1 parent 1c6f8ec commit 28b3571

24 files changed

+60
-54
lines changed

.github/workflows/test_full.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,5 @@ jobs:
4141
run: flit install --symlink
4242
- name: Black
4343
run: black --check ninja_jwt tests
44-
- name: isort
45-
run: isort --check ninja_jwt tests
46-
- name: Flake8
47-
run: flake8 ninja_jwt tests
48-
# - name: mypy
49-
# run: mypy ninja_jwt
44+
- name: Ruff Linting Check
45+
run: ruff check ninja_jwt tests

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@ install: ## Install dependencies
1818
lint: ## Run code linters
1919
make clean
2020
black --check ninja_jwt tests
21-
isort --check ninja_jwt tests
22-
flake8 ninja_jwt tests
21+
ruff check ninja_jwt tests
2322
# mypy ninja_jwt
2423

2524
fmt format: ## Run code formatters
2625
make clean
2726
black ninja_jwt tests
28-
isort ninja_jwt tests
27+
ruff check --fix ninja_jwt tests
2928

3029
test: ## Run tests
3130
make clean

mypy.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[mypy]
2-
python_version = 3.6
2+
python_version = 3.8
33

44
show_column_numbers = True
55

@@ -21,4 +21,4 @@ no_implicit_reexport = True
2121
[mypy-ninja_jwt.token_blacklist.*]
2222
ignore_errors = True
2323
[mypy-ninja_jwt.controller]
24-
ignore_errors = True
24+
ignore_errors = True

ninja_jwt/authentication.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ def get_user(self, validated_token) -> Type[AbstractUser]:
4949
"""
5050
try:
5151
user_id = validated_token[api_settings.USER_ID_CLAIM]
52-
except KeyError:
53-
raise InvalidToken(_("Token contained no recognizable user identification"))
52+
except KeyError as e:
53+
raise InvalidToken(
54+
_("Token contained no recognizable user identification")
55+
) from e
5456

5557
try:
5658
user = self.user_model.objects.get(**{api_settings.USER_ID_FIELD: user_id})
57-
except self.user_model.DoesNotExist:
58-
raise AuthenticationFailed(_("User not found"))
59+
except self.user_model.DoesNotExist as e:
60+
raise AuthenticationFailed(_("User not found")) from e
5961

6062
if not user.is_active:
6163
raise AuthenticationFailed(_("User is inactive"))

ninja_jwt/schema.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def to_response_schema(self):
3939

4040

4141
class TokenInputSchemaMixin(InputSchemaMixin):
42-
4342
_user: Optional[AbstractUser] = None
4443

4544
_default_error_messages = {

ninja_jwt/settings.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ def __init__(self, data: dict) -> None:
1313
self.__dict__ = data
1414

1515

16-
NinjaJWT_SETTINGS_DEFAULTS = dict(
17-
USER_AUTHENTICATION_RULE="ninja_jwt.authentication.default_user_authentication_rule",
18-
AUTH_TOKEN_CLASSES=["ninja_jwt.tokens.AccessToken"],
19-
TOKEN_USER_CLASS="ninja_jwt.models.TokenUser",
20-
)
16+
NinjaJWT_SETTINGS_DEFAULTS = {
17+
"USER_AUTHENTICATION_RULE": "ninja_jwt.authentication.default_user_authentication_rule",
18+
"AUTH_TOKEN_CLASSES": ["ninja_jwt.tokens.AccessToken"],
19+
"TOKEN_USER_CLASS": "ninja_jwt.models.TokenUser",
20+
}
2121

2222
USER_SETTINGS = NinjaJWTUserDefinedSettingsMapper(
2323
getattr(

ninja_jwt/token_blacklist/migrations/0001_initial.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55

66
class Migration(migrations.Migration):
7-
87
initial = True
98

109
dependencies = [

ninja_jwt/token_blacklist/migrations/0002_outstandingtoken_jti_hex.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33

44
class Migration(migrations.Migration):
5-
65
dependencies = [
76
("token_blacklist", "0001_initial"),
87
]

ninja_jwt/token_blacklist/migrations/0003_auto_20171017_2007.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def reverse_populate_jti_hex(apps, schema_editor): # pragma: no cover
2222

2323

2424
class Migration(migrations.Migration):
25-
2625
dependencies = [
2726
("token_blacklist", "0002_outstandingtoken_jti_hex"),
2827
]

ninja_jwt/token_blacklist/migrations/0004_auto_20171017_2013.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33

44
class Migration(migrations.Migration):
5-
65
dependencies = [
76
("token_blacklist", "0003_auto_20171017_2007"),
87
]

0 commit comments

Comments
 (0)