refactor(project): make pyright & ruff happy
This commit is contained in:
@@ -55,14 +55,9 @@ class GeoIPHelper:
|
||||
- 临时目录退出后自动清理
|
||||
"""
|
||||
if not self.license_key:
|
||||
raise ValueError(
|
||||
"缺少 MaxMind License Key,请传入或设置环境变量 MAXMIND_LICENSE_KEY"
|
||||
)
|
||||
raise ValueError("缺少 MaxMind License Key,请传入或设置环境变量 MAXMIND_LICENSE_KEY")
|
||||
|
||||
url = (
|
||||
f"{BASE_URL}?edition_id={edition_id}&"
|
||||
f"license_key={self.license_key}&suffix=tar.gz"
|
||||
)
|
||||
url = f"{BASE_URL}?edition_id={edition_id}&license_key={self.license_key}&suffix=tar.gz"
|
||||
|
||||
with httpx.Client(follow_redirects=True, timeout=self.timeout) as client:
|
||||
with client.stream("GET", url) as resp:
|
||||
|
||||
@@ -48,8 +48,7 @@ class RateLimiter:
|
||||
|
||||
if wait_time > 0:
|
||||
logger.opt(colors=True).info(
|
||||
f"<yellow>[RateLimiter]</yellow> Rate limit reached, "
|
||||
f"waiting {wait_time:.2f}s"
|
||||
f"<yellow>[RateLimiter]</yellow> Rate limit reached, waiting {wait_time:.2f}s"
|
||||
)
|
||||
await asyncio.sleep(wait_time)
|
||||
current_time = time.time()
|
||||
@@ -107,11 +106,7 @@ class RateLimiter:
|
||||
"max_requests_per_minute": self.max_requests_per_minute,
|
||||
"burst_requests": len(self.burst_times),
|
||||
"burst_limit": self.burst_limit,
|
||||
"next_reset_in_seconds": (
|
||||
60.0 - (current_time - self.request_times[0])
|
||||
if self.request_times
|
||||
else 0.0
|
||||
),
|
||||
"next_reset_in_seconds": (60.0 - (current_time - self.request_times[0]) if self.request_times else 0.0),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user