Skip to content

Commit

Permalink
update gitignore and fix customizable retries and backoff
Browse files Browse the repository at this point in the history
  • Loading branch information
uberfastman committed Jul 16, 2023
1 parent d9ee247 commit cec56db
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
27 changes: 15 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
# Byte-compiled / optimized / DLL files
# python
__pycache__/
*.py[cod]

# Miscelleanous
.DS_Store

# JetBrains IDE project files
.idea/*

# Distribution / packaging
# build
.Python
build/
dist/
*.egg-info/

# miscelleanous
.DS_Store

# development
.idea/*
.vscode

# Testing
.pytest_cache/
test_output/
private*.json
token*.json

# Environment
*.env
*.venv
!EXAMPLE.env
.python-version

.vscode
.python-version
# Credentials
private*.json
token*.json
1 change: 0 additions & 1 deletion .venv

This file was deleted.

7 changes: 4 additions & 3 deletions yfpy/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,21 @@ def _authenticate(self) -> None:
if not self.oauth.token_is_valid():
self.oauth.refresh_access_token()

def get_response(self, url: str) -> Response:
def get_response(self, url: str, retries: int = self._retries, backoff: int = self._backoff) -> Response:
"""Retrieve Yahoo Fantasy Sports data from the REST API.
Args:
url (str): REST API request URL string.
retries (:obj:`int`, optional): Number of times to retry a query if it fails (defaults to 3).
backoff (:obj:`int`, optional): Multiplier that incrementally increases the wait time before retrying a
failed query request.
Returns:
Response: API response from Yahoo Fantasy Sports API request.
"""
logger.debug(f"Making request to URL: {url}")
response = self.oauth.session.get(url, params={"format": "json"}) # type: Response
retries = self._retries
backoff = self._backoff

status_code = response.status_code
# when you exceed Yahoo's allowed data request limits, they throw a request status code of 999
Expand Down

0 comments on commit cec56db

Please sign in to comment.