Skip to content

Commit dfb8de4

Browse files
committed
refactor: Remove unused variables
1 parent 63357ac commit dfb8de4

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

supertokens_python/recipe/session/constants.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
available_token_transfer_methods: List[TokenTransferMethod] = ["cookie", "header"]
3535

3636
JWKCacheMaxAgeInMs = 6 * 1000 # 6s
37-
JWKRequestCooldownInMs = 500 # 0.5s
3837
protected_props = [
3938
"sub",
4039
"iat",

supertokens_python/recipe/session/jwks.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from jwt import PyJWK, PyJWKSet
2121

22-
from .constants import JWKCacheMaxAgeInMs, JWKRequestCooldownInMs
22+
from .constants import JWKCacheMaxAgeInMs
2323

2424
from supertokens_python.utils import RWMutex, RWLockContext, get_timestamp_ms
2525
from supertokens_python.querier import Querier
@@ -38,8 +38,7 @@ class JWKSConfigType(TypedDict):
3838

3939

4040
class CachedKeys:
41-
def __init__(self, path: str, keys: List[PyJWK]):
42-
self.path = path
41+
def __init__(self, keys: List[PyJWK]):
4342
self.keys = keys
4443
self.last_refresh_time = get_timestamp_ms()
4544

@@ -121,9 +120,8 @@ def get_latest_keys(kid: Optional[str] = None) -> List[PyJWK]:
121120
last_error = e
122121

123122
if cached_jwks is not None: # we found a valid JWKS
124-
cached_keys = CachedKeys(path, cached_jwks)
123+
cached_keys = CachedKeys(cached_jwks)
125124
log_debug_message("Returning JWKS from fetch")
126125
return cached_keys.keys
127126

128127
raise last_error
129-

tests/test_utils.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,26 @@ class BankAccount:
112112
def __init__(self):
113113
self.balance = 0
114114
self.mutex = RWMutex()
115+
self.deposit_count = 0
116+
self.withdraw_count = 0
115117

116118
def deposit(self, amount: int):
117119
self.mutex.lock()
118120
self.balance += amount
121+
self.deposit_count += 1
119122
self.mutex.unlock()
120123

121124
def withdraw(self, amount: int):
122125
self.mutex.lock()
123126
self.balance -= amount
127+
self.withdraw_count += 1
124128
self.mutex.unlock()
125129

126-
def get_balance(self):
130+
def get_stats(self):
127131
self.mutex.r_lock()
128132
balance = self.balance
129133
self.mutex.r_unlock()
130-
return balance
134+
return balance, (self.deposit_count, self.withdraw_count)
131135

132136

133137
def test_rw_mutex_writes():
@@ -140,8 +144,9 @@ def test_rw_mutex_writes():
140144
threads.append(t)
141145

142146
def balance_is_valid():
143-
balance = account.get_balance()
144-
assert balance % 5 == 0 and balance >= 0
147+
balance, (deposit_count, widthdraw_count) = account.get_stats()
148+
expected_balance = 10 * deposit_count - 5 * widthdraw_count
149+
assert balance == expected_balance
145150

146151
# Create 15 balance checking threads
147152
for _ in range(15):
@@ -164,4 +169,5 @@ def balance_is_valid():
164169
# Check account balance
165170
expected_balance = 10 * 10 # 10 threads depositing 10 each
166171
expected_balance -= 10 * 5 # 10 threads withdrawing 5 each
167-
assert account.get_balance() == expected_balance, "Incorrect account balance"
172+
actual_balance, _ = account.get_stats()
173+
assert actual_balance == expected_balance, "Incorrect account balance"

0 commit comments

Comments
 (0)