Enable ruff S113 rule (#11375)

* Enable ruff S113 rule

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Maxim Smolskiy
2024-04-21 20:34:18 +03:00
committed by GitHub
parent 7b88e15b1c
commit 2702bf9400
36 changed files with 68 additions and 46 deletions

View File

@ -9,14 +9,14 @@ def get_apod_data(api_key: str) -> dict:
Get your API Key from: https://api.nasa.gov/
"""
url = "https://api.nasa.gov/planetary/apod"
return requests.get(url, params={"api_key": api_key}).json()
return requests.get(url, params={"api_key": api_key}, timeout=10).json()
def save_apod(api_key: str, path: str = ".") -> dict:
apod_data = get_apod_data(api_key)
img_url = apod_data["url"]
img_name = img_url.split("/")[-1]
response = requests.get(img_url, stream=True)
response = requests.get(img_url, stream=True, timeout=10)
with open(f"{path}/{img_name}", "wb+") as img_file:
shutil.copyfileobj(response.raw, img_file)
@ -29,7 +29,7 @@ def get_archive_data(query: str) -> dict:
Get the data of a particular query from NASA archives
"""
url = "https://images-api.nasa.gov/search"
return requests.get(url, params={"q": query}).json()
return requests.get(url, params={"q": query}, timeout=10).json()
if __name__ == "__main__":