Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ test_output/
*private*.json
!private.template.json
*token*.json
venv/
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ include LICENSE
include requirements.txt
include requirements-dev.txt

# Include version bounds file
include VERSION_PYTHON.py

# Include Yahoo Fantasy Sports REST API authentication resources
include .env.template

Expand Down
4 changes: 2 additions & 2 deletions VERSION.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# DO NOT EDIT - VERSIONING CONTROLLED BY GIT TAGS
__version__ = "v16.0.3"
# DO NOT EDIT - VERSIONING CONTROLLED BY GIT TAGS
__version__ = "v16.0.3"
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
"ruamel.yaml"
]
build-backend = "setuptools.build_meta"
21 changes: 20 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,28 @@
import setuptools
from ruamel.yaml import YAML

from VERSION_PYTHON import __version_minimum_python__, __version_maximum_python__
# --- Load supported Python version bounds without importing the module (import failed in build isolation) ---
# We avoid `import VERSION_PYTHON` because during `pip install .` (PEP 517 isolated build) the project root
# may not yet be reliably on sys.path when setuptools initially evaluates setup.py for build requirements.
def _read_version_bounds(version_file_path: Path):
minimum = "3.10" # sensible defaults if file missing
maximum = "3.12"
if version_file_path.exists():
try:
for line in version_file_path.read_text(encoding="utf-8").splitlines():
if line.startswith("__version_minimum_python__"):
minimum = line.split("=")[-1].strip().strip('"').strip("'")
elif line.startswith("__version_maximum_python__"):
maximum = line.split("=")[-1].strip().strip('"').strip("'")
except Exception:
# Fall back to defaults if parsing somehow fails
pass
return minimum, maximum

project_root_dir = Path(__file__).parent
_min_py, _max_py = _read_version_bounds(project_root_dir / "VERSION_PYTHON.py")
__version_minimum_python__, __version_maximum_python__ = _min_py, _max_py


version_file = project_root_dir / "VERSION.py"

Expand Down
57 changes: 55 additions & 2 deletions yfpy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ def __init__(self, extracted_data):
team_projected_points (TeamProjectedPoints): A YFPY TeamProjectedPoints instance.
projected_points (float): The total projected points for the team.
team_standings (TeamStandings): A YFPY TeamStandings instance.
team_stats (TeamStats): A YFPY TeamStats instance containing the team's statistics.
team_remaining_games (TeamRemainingGames): A YFPY TeamRemainingGames instance containing information about
remaining games for the team.
wins (int): The number of wins by the team.
losses (int): The number of losses by the team.
ties (int): The number of ties by the team.
Expand Down Expand Up @@ -587,10 +590,11 @@ def __init__(self, extracted_data):
self.team_paid: int = self._extracted_data.get("team_paid", 0)
self.team_points: TeamPoints = self._extracted_data.get("team_points", TeamPoints({}))
self.points: float = self._get_nested_value(self.team_points, "total", 0.0, float)
self.team_projected_points: TeamProjectedPoints = self._extracted_data.get("team_projected_points",
TeamProjectedPoints({}))
self.team_projected_points: TeamProjectedPoints = self._extracted_data.get("team_projected_points", TeamProjectedPoints({}))
self.projected_points: float = self._get_nested_value(self.team_projected_points, "total", 0.0, float)
self.team_standings: TeamStandings = self._extracted_data.get("team_standings", TeamStandings({}))
self.team_stats: TeamStats = self._extracted_data.get("team_stats", TeamStats({}))
self.team_remaining_games: TeamRemainingGames = self._extracted_data.get("team_remaining_games", TeamRemainingGames({}))
self.wins: int = self._get_nested_value(self.team_standings, ["outcome_totals", "wins"], 0, int)
self.losses: int = self._get_nested_value(self.team_standings, ["outcome_totals", "losses"], 0, int)
self.ties: int = self._get_nested_value(self.team_standings, ["outcome_totals", "ties"], 0, int)
Expand Down Expand Up @@ -887,6 +891,55 @@ def __init__(self, extracted_data):
self.total: float = self._get_nested_value(self._extracted_data, "total", 0.0, float)
self.week: Optional[int] = self._extracted_data.get("week", None)

# noinspection PyUnresolvedReferences
class TeamRemainingGames(YahooFantasyObject):
"""Model class for "team_remaining_games" data key.
"""

def __init__(self, extracted_data):
"""Instantiate the TeamRemainingGames child class of YahooFantasyObject.

Args:
extracted_data (dict): Parsed and cleaned JSON data retrieved from the Yahoo Fantasy Sports REST API.

Attributes:
coverage_type (str): The timeframe for the remaining games data ("week", "date", "season", etc.).
week (int): The week number.
total (dict): Dictionary containing remaining games statistics:
remaining_games (int): Number of remaining games.
live_games (int): Number of currently live games.
completed_games (int): Number of completed games.
"""
YahooFantasyObject.__init__(self, extracted_data)
self.coverage_type: str = self._extracted_data.get("coverage_type", "")
self.week: Optional[int] = self._extracted_data.get("week", None)
self.total: dict = self._extracted_data.get("total", {})
self.remaining_games: int = self._get_nested_value(self.total, "remaining_games", 0, int)
self.live_games: int = self._get_nested_value(self.total, "live_games", 0, int)
self.completed_games: int = self._get_nested_value(self.total, "completed_games", 0, int)


# noinspection PyUnresolvedReferences
class TeamStats(YahooFantasyObject):
"""Model class for "team_stats" data key.
"""

def __init__(self, extracted_data):
"""Instantiate the TeamStats child class of YahooFantasyObject.

Args:
extracted_data (dict): Parsed and cleaned JSON data retrieved from the Yahoo Fantasy Sports REST API.

Attributes:
coverage_type (str): The timeframe for the selected team stats ("week", "date", "season", etc.).
week (int): The week number.
stats (list[Stat]): List of Stat objects containing the team's statistics.
"""
YahooFantasyObject.__init__(self, extracted_data)
self.coverage_type: str = self._extracted_data.get("coverage_type", "")
self.week: Optional[int] = self._extracted_data.get("week", None)
self.stats: List[Stat] = self._extracted_data.get("stats", [])


# noinspection PyUnresolvedReferences
class TeamStandings(YahooFantasyObject):
Expand Down
Loading