Skip to content

Commit

Permalink
Merge pull request #42 from a-luna:fix-redis-client-lock_20240325
Browse files Browse the repository at this point in the history
Update linting configuration and refactor TestRedisClient lock method
  • Loading branch information
a-luna authored Mar 25, 2024
2 parents f857281 + 000acdb commit a64d83c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
9 changes: 7 additions & 2 deletions app/core/redis_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
import os
import time
from contextlib import contextmanager
from datetime import datetime
from typing import Any, Protocol

Expand Down Expand Up @@ -146,7 +146,7 @@ def client(self) -> Redis:
return FakeRedis()

def lock(self, name: str, blocking_timeout: float | int) -> Any:
return self.client.lock(name, blocking_timeout=blocking_timeout)
return fake_lock_context()

def setnx(self, name: RedisKey, value: RedisValue) -> RedisResponse:
if name not in self.db:
Expand All @@ -165,4 +165,9 @@ def now(self) -> datetime:
return dtaware_fromtimestamp(self.time())


@contextmanager
def fake_lock_context():
yield None


redis = TestRedisClient() if get_settings().is_test else RedisClient()
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"∑", # U+2211 N-ARY SUMMATION (Math Symbol)
"㑢", # U+3462 CJK UNIFIED IDEOGRAPH-3462 (CJK Ideograph)
"穩", # U+7A69 CJK UNIFIED IDEOGRAPH-7A69 (CJK Ideograph w/ variants)
"范", # U+8303 CJK UNIFIED IDEOGRAPH-8303 (CJK Ideograph w/ multiple values for totalStrokes)
# "\uda92", # U+DA92 <surrogate-DA92> (High-Surrogate)
# "\udddd", # U+DDDD <surrogate-DDDD> (Low Surrogate)
"范", # U+8303 CJK UNIFIED IDEOGRAPH-8303 (CJK Ideograph w/ multiple values for totalStrokes) # noqa: E501
# "\uda92", # U+DA92 <surrogate-DA92> (High-Surrogate) # noqa: ERA001, E501
# "\udddd", # U+DDDD <surrogate-DDDD> (Low Surrogate) # noqa: ERA001, E501
"﨑", # U+FA11 CJK COMPATIBILITY IDEOGRAPH-FA11 (CJK Compatibility Ideograph)
"\uf800", # U+F800 <private-use-F800> (Private Use)
"\ufffe", # U+FFFE <noncharacter-FFFE> (Noncharacter)
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ exclude = '''

[tool.ruff]
line-length = 120

[tool.ruff.lint]
select = ["B", "C4", "C90", "E", "ERA", "F", "FA", "I", "INT", "N", "PERF", "PGH", "PIE", "PLE", "PLW", "PTH", "RUF100", "SIM", "UP", "W", "YTT"]
extend-select = ["I"]
ignore = ["B019", "B905"]
fixable = ["I"]
unfixable = ["B", "C90", "PIE", "SIM"]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"app/api/api_v1/dependencies.py" = ["E501"]
"app/docs/dependencies/custom_parameters.py" = ["E501"]
"app/docs/dependencies/filter_tables.py" = ["E501"]
Expand Down

0 comments on commit a64d83c

Please sign in to comment.