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

Add type hints (PEP 484) #10

Merged
merged 1 commit into from
Jul 10, 2021
Merged
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
5 changes: 3 additions & 2 deletions is_even/is_even.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import requests
from functools import lru_cache
from retry import retry
from typing import Union


@lru_cache(maxsize=None)
@retry(ConnectionError, tries=3, delay=2)
def is_even(number):
def is_even(number: Union[str, int]) -> bool:
n = int(number)
r = requests.get(f"https://api.isevenapi.xyz/api/iseven/{n}/")

Expand All @@ -15,7 +16,7 @@ def is_even(number):
raise Exception(r.json()["error"])


def is_odd(number):
def is_odd(number: Union[str, int]) -> bool:
return not is_even(number)


Expand Down