Skip to content

Commit 1b0520a

Browse files
[pre-commit.ci] pre-commit autoupdate (#1540)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.6 → v0.9.1](astral-sh/ruff-pre-commit@v0.8.6...v0.9.1) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent c61d852 commit 1b0520a

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.8.6
3+
rev: v0.9.1
44
hooks:
55
- id: ruff
66
args: [ --fix ]

oauth2_provider/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ def batch_delete(queryset, query):
715715
flat_queryset = queryset.values_list("id", flat=True)[:CLEAR_EXPIRED_TOKENS_BATCH_SIZE]
716716
batch_length = flat_queryset.count()
717717
queryset.model.objects.filter(id__in=list(flat_queryset)).delete()
718-
logger.debug(f"{batch_length} tokens deleted, {current_no-batch_length} left")
718+
logger.debug(f"{batch_length} tokens deleted, {current_no - batch_length} left")
719719
queryset = queryset.model.objects.filter(query)
720720
time.sleep(CLEAR_EXPIRED_TOKENS_BATCH_INTERVAL)
721721
current_no = queryset.count()

tests/test_models.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -433,41 +433,41 @@ def test_clear_expired_tokens_with_tokens(self):
433433
initial_at_count = AccessToken.objects.count()
434434
assert initial_at_count == 2 * self.num_tokens, f"{2 * self.num_tokens} access tokens should exist."
435435
initial_expired_at_count = AccessToken.objects.filter(expires__lte=self.now).count()
436-
assert (
437-
initial_expired_at_count == self.num_tokens
438-
), f"{self.num_tokens} expired access tokens should exist."
436+
assert initial_expired_at_count == self.num_tokens, (
437+
f"{self.num_tokens} expired access tokens should exist."
438+
)
439439
initial_current_at_count = AccessToken.objects.filter(expires__gt=self.now).count()
440-
assert (
441-
initial_current_at_count == self.num_tokens
442-
), f"{self.num_tokens} current access tokens should exist."
440+
assert initial_current_at_count == self.num_tokens, (
441+
f"{self.num_tokens} current access tokens should exist."
442+
)
443443
initial_rt_count = RefreshToken.objects.count()
444-
assert (
445-
initial_rt_count == self.num_tokens // 2
446-
), f"{self.num_tokens // 2} refresh tokens should exist."
444+
assert initial_rt_count == self.num_tokens // 2, (
445+
f"{self.num_tokens // 2} refresh tokens should exist."
446+
)
447447
initial_rt_expired_at_count = RefreshToken.objects.filter(access_token__expires__lte=self.now).count()
448-
assert (
449-
initial_rt_expired_at_count == initial_rt_count / 2
450-
), "half the refresh tokens should be for expired access tokens."
448+
assert initial_rt_expired_at_count == initial_rt_count / 2, (
449+
"half the refresh tokens should be for expired access tokens."
450+
)
451451
initial_rt_current_at_count = RefreshToken.objects.filter(access_token__expires__gt=self.now).count()
452-
assert (
453-
initial_rt_current_at_count == initial_rt_count / 2
454-
), "half the refresh tokens should be for current access tokens."
452+
assert initial_rt_current_at_count == initial_rt_count / 2, (
453+
"half the refresh tokens should be for current access tokens."
454+
)
455455
initial_gt_count = Grant.objects.count()
456456
assert initial_gt_count == self.num_tokens * 2, f"{self.num_tokens * 2} grants should exist."
457457

458458
clear_expired()
459459

460460
# after clear_expired():
461461
remaining_at_count = AccessToken.objects.count()
462-
assert (
463-
remaining_at_count == initial_at_count // 2
464-
), "half the initial access tokens should still exist."
462+
assert remaining_at_count == initial_at_count // 2, (
463+
"half the initial access tokens should still exist."
464+
)
465465
remaining_expired_at_count = AccessToken.objects.filter(expires__lte=self.now).count()
466466
assert remaining_expired_at_count == 0, "no remaining expired access tokens should still exist."
467467
remaining_current_at_count = AccessToken.objects.filter(expires__gt=self.now).count()
468-
assert (
469-
remaining_current_at_count == initial_current_at_count
470-
), "all current access tokens should still exist."
468+
assert remaining_current_at_count == initial_current_at_count, (
469+
"all current access tokens should still exist."
470+
)
471471
remaining_rt_count = RefreshToken.objects.count()
472472
assert remaining_rt_count == initial_rt_count // 2, "half the refresh tokens should still exist."
473473
remaining_rt_expired_at_count = RefreshToken.objects.filter(
@@ -477,9 +477,9 @@ def test_clear_expired_tokens_with_tokens(self):
477477
remaining_rt_current_at_count = RefreshToken.objects.filter(
478478
access_token__expires__gt=self.now
479479
).count()
480-
assert (
481-
remaining_rt_current_at_count == initial_rt_current_at_count
482-
), "all the refresh tokens for current access tokens should still exist."
480+
assert remaining_rt_current_at_count == initial_rt_current_at_count, (
481+
"all the refresh tokens for current access tokens should still exist."
482+
)
483483
remaining_gt_count = Grant.objects.count()
484484
assert remaining_gt_count == initial_gt_count // 2, "half the remaining grants should still exist."
485485

0 commit comments

Comments
 (0)