Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Mutable Default Arguments and corrected type hints #243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/riotwatcher/Handlers/RateLimit/OopsRateLimiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self):
def friendly_name(self) -> str:
return self._friendly_name

def wait_until(self, region: str, endpoint_name: str, method_name: str) -> datetime:
def wait_until(self, region: str, endpoint_name: str, method_name: str) -> datetime.datetime:
if self._retry_at is not None:
if self._retry_at > datetime.datetime.now():
return self._retry_at
Expand Down
6 changes: 3 additions & 3 deletions src/riotwatcher/LolWatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class LolWatcher:

def __init__(
self,
api_key: str = None,
timeout: int = None,
kernel_url: str = None,
api_key: str | None = None,
timeout: int | None = None,
kernel_url: str | None = None,
rate_limiter: RateLimiter = BasicRateLimiter(),
deserializer: Deserializer = DictionaryDeserializer(),
default_status_v4: bool = False,
Expand Down
14 changes: 9 additions & 5 deletions src/riotwatcher/LorWatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class LorWatcher:

def __init__(
self,
api_key: str = None,
timeout: int = None,
rate_limiter: RateLimiter = BasicRateLimiter(),
deserializer: Deserializer = DictionaryDeserializer(),
api_key: str | None = None,
timeout: int | None = None,
rate_limiter: RateLimiter | None = None,
deserializer: Deserializer | None = None,
):
"""
Initialize a new instance of the LorWatcher class.
Expand All @@ -42,8 +42,12 @@ def __init__(
from the Riot Api. Default is
Handlers.DictionaryDeserializer.
"""
if not api_key:
if api_key is None:
raise ValueError("api_key must be set!")
if rate_limiter is None:
rate_limiter = BasicRateLimiter()
if deserializer is None:
deserializer = DictionaryDeserializer()

handler_chain = [
SanitationHandler(),
Expand Down
6 changes: 3 additions & 3 deletions src/riotwatcher/TftWatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class TftWatcher:

def __init__(
self,
api_key: str = None,
timeout: int = None,
api_key: str | None = None,
timeout: int | None = None,
rate_limiter: RateLimiter = BasicRateLimiter(),
deserializer: Deserializer = DictionaryDeserializer(),
):
Expand All @@ -43,7 +43,7 @@ def __init__(
from the Riot Api. Default is
Handlers.DictionaryDeserializer.
"""
if not api_key:
if api_key is None:
raise ValueError("api_key must be set!")

handler_chain = [
Expand Down
2 changes: 1 addition & 1 deletion src/riotwatcher/ValWatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ValWatcher:
def __init__(
self,
api_key: str,
timeout: int = None,
timeout: int | None = None,
rate_limiter: RateLimiter = BasicRateLimiter(),
deserializer: Deserializer = DictionaryDeserializer(),
):
Expand Down
2 changes: 1 addition & 1 deletion src/riotwatcher/riotwatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class RiotWatcher:
def __init__(
self,
api_key: str,
timeout: int = None,
timeout: int | None = None,
rate_limiter: RateLimiter = BasicRateLimiter(),
deserializer: Deserializer = DictionaryDeserializer(),
):
Expand Down