cfb-data 0.4.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. cfb_data/__init__.py +234 -0
  2. cfb_data/_dataframes.py +279 -0
  3. cfb_data/_executor.py +129 -0
  4. cfb_data/_parquet.py +197 -0
  5. cfb_data/_request_rules.py +41 -0
  6. cfb_data/_requests.py +36 -0
  7. cfb_data/_tabular.py +676 -0
  8. cfb_data/_transport.py +452 -0
  9. cfb_data/adjusted_metrics/__init__.py +29 -0
  10. cfb_data/adjusted_metrics/models/__init__.py +1 -0
  11. cfb_data/adjusted_metrics/models/pydantic/__init__.py +29 -0
  12. cfb_data/adjusted_metrics/models/pydantic/requests.py +45 -0
  13. cfb_data/adjusted_metrics/models/pydantic/responses.py +88 -0
  14. cfb_data/adjusted_metrics/resource.py +220 -0
  15. cfb_data/base/__init__.py +6 -0
  16. cfb_data/base/types.py +112 -0
  17. cfb_data/betting/__init__.py +15 -0
  18. cfb_data/betting/models/__init__.py +1 -0
  19. cfb_data/betting/models/pydantic/__init__.py +6 -0
  20. cfb_data/betting/models/pydantic/requests.py +35 -0
  21. cfb_data/betting/models/pydantic/responses.py +62 -0
  22. cfb_data/betting/resource.py +91 -0
  23. cfb_data/client.py +305 -0
  24. cfb_data/coaches/__init__.py +57 -0
  25. cfb_data/coaches/models/__init__.py +1 -0
  26. cfb_data/coaches/models/pydantic/__init__.py +57 -0
  27. cfb_data/coaches/models/pydantic/requests.py +75 -0
  28. cfb_data/coaches/models/pydantic/responses.py +261 -0
  29. cfb_data/coaches/resource.py +216 -0
  30. cfb_data/conferences/__init__.py +23 -0
  31. cfb_data/conferences/models/__init__.py +1 -0
  32. cfb_data/conferences/models/pydantic/__init__.py +23 -0
  33. cfb_data/conferences/models/pydantic/requests.py +69 -0
  34. cfb_data/conferences/models/pydantic/responses.py +64 -0
  35. cfb_data/conferences/resource.py +175 -0
  36. cfb_data/draft/__init__.py +19 -0
  37. cfb_data/draft/models/__init__.py +1 -0
  38. cfb_data/draft/models/pydantic/__init__.py +12 -0
  39. cfb_data/draft/models/pydantic/requests.py +18 -0
  40. cfb_data/draft/models/pydantic/responses.py +65 -0
  41. cfb_data/draft/resource.py +132 -0
  42. cfb_data/drives/__init__.py +13 -0
  43. cfb_data/drives/models/__init__.py +1 -0
  44. cfb_data/drives/models/pydantic/__init__.py +17 -0
  45. cfb_data/drives/models/pydantic/requests.py +42 -0
  46. cfb_data/drives/models/pydantic/responses.py +46 -0
  47. cfb_data/drives/resource.py +94 -0
  48. cfb_data/enums.py +93 -0
  49. cfb_data/errors.py +234 -0
  50. cfb_data/games/__init__.py +42 -0
  51. cfb_data/games/models/__init__.py +1 -0
  52. cfb_data/games/models/pydantic/__init__.py +106 -0
  53. cfb_data/games/models/pydantic/requests.py +266 -0
  54. cfb_data/games/models/pydantic/responses.py +495 -0
  55. cfb_data/games/resource.py +486 -0
  56. cfb_data/info/__init__.py +25 -0
  57. cfb_data/info/models/__init__.py +1 -0
  58. cfb_data/info/models/pydantic/__init__.py +23 -0
  59. cfb_data/info/models/pydantic/requests.py +18 -0
  60. cfb_data/info/models/pydantic/responses.py +103 -0
  61. cfb_data/info/resource.py +88 -0
  62. cfb_data/metrics/__init__.py +53 -0
  63. cfb_data/metrics/models/__init__.py +1 -0
  64. cfb_data/metrics/models/pydantic/__init__.py +49 -0
  65. cfb_data/metrics/models/pydantic/requests.py +121 -0
  66. cfb_data/metrics/models/pydantic/responses.py +182 -0
  67. cfb_data/metrics/resource.py +371 -0
  68. cfb_data/players/__init__.py +44 -0
  69. cfb_data/players/models/__init__.py +1 -0
  70. cfb_data/players/models/pydantic/__init__.py +41 -0
  71. cfb_data/players/models/pydantic/requests.py +70 -0
  72. cfb_data/players/models/pydantic/responses.py +171 -0
  73. cfb_data/players/resource.py +258 -0
  74. cfb_data/playoffs/__init__.py +41 -0
  75. cfb_data/playoffs/models/__init__.py +1 -0
  76. cfb_data/playoffs/models/pydantic/__init__.py +37 -0
  77. cfb_data/playoffs/models/pydantic/requests.py +30 -0
  78. cfb_data/playoffs/models/pydantic/responses.py +173 -0
  79. cfb_data/playoffs/resource.py +149 -0
  80. cfb_data/plays/__init__.py +43 -0
  81. cfb_data/plays/models/__init__.py +1 -0
  82. cfb_data/plays/models/pydantic/__init__.py +35 -0
  83. cfb_data/plays/models/pydantic/requests.py +85 -0
  84. cfb_data/plays/models/pydantic/responses.py +231 -0
  85. cfb_data/plays/resource.py +249 -0
  86. cfb_data/py.typed +0 -0
  87. cfb_data/rankings/__init__.py +16 -0
  88. cfb_data/rankings/models/__init__.py +1 -0
  89. cfb_data/rankings/models/pydantic/__init__.py +6 -0
  90. cfb_data/rankings/models/pydantic/requests.py +36 -0
  91. cfb_data/rankings/models/pydantic/responses.py +42 -0
  92. cfb_data/rankings/resource.py +89 -0
  93. cfb_data/ratings/__init__.py +59 -0
  94. cfb_data/ratings/models/__init__.py +1 -0
  95. cfb_data/ratings/models/pydantic/__init__.py +55 -0
  96. cfb_data/ratings/models/pydantic/requests.py +87 -0
  97. cfb_data/ratings/models/pydantic/responses.py +215 -0
  98. cfb_data/ratings/resource.py +342 -0
  99. cfb_data/recruiting/__init__.py +26 -0
  100. cfb_data/recruiting/models/__init__.py +1 -0
  101. cfb_data/recruiting/models/pydantic/__init__.py +23 -0
  102. cfb_data/recruiting/models/pydantic/requests.py +69 -0
  103. cfb_data/recruiting/models/pydantic/responses.py +70 -0
  104. cfb_data/recruiting/resource.py +180 -0
  105. cfb_data/retry.py +49 -0
  106. cfb_data/stats/__init__.py +69 -0
  107. cfb_data/stats/models/__init__.py +1 -0
  108. cfb_data/stats/models/pydantic/__init__.py +65 -0
  109. cfb_data/stats/models/pydantic/requests.py +167 -0
  110. cfb_data/stats/models/pydantic/responses.py +291 -0
  111. cfb_data/stats/resource.py +400 -0
  112. cfb_data/teams/__init__.py +40 -0
  113. cfb_data/teams/models/__init__.py +1 -0
  114. cfb_data/teams/models/pydantic/__init__.py +26 -0
  115. cfb_data/teams/models/pydantic/requests.py +96 -0
  116. cfb_data/teams/models/pydantic/responses.py +116 -0
  117. cfb_data/teams/resource.py +270 -0
  118. cfb_data/venues/__init__.py +6 -0
  119. cfb_data/venues/models/__init__.py +1 -0
  120. cfb_data/venues/models/pydantic/__init__.py +5 -0
  121. cfb_data/venues/models/pydantic/responses.py +24 -0
  122. cfb_data/venues/resource.py +51 -0
  123. cfb_data-0.4.1.dist-info/METADATA +414 -0
  124. cfb_data-0.4.1.dist-info/RECORD +127 -0
  125. cfb_data-0.4.1.dist-info/WHEEL +5 -0
  126. cfb_data-0.4.1.dist-info/licenses/LICENSE +21 -0
  127. cfb_data-0.4.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,266 @@
1
+ """Validate request parameters for implemented Games endpoints."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Self
6
+
7
+ from pydantic import BaseModel, ConfigDict, Field, model_validator
8
+
9
+ from cfb_data._request_rules import (
10
+ _validate_at_least_one_of,
11
+ _validate_game_stats_selectors,
12
+ _validate_year_or_game_id,
13
+ )
14
+ from cfb_data.enums import (
15
+ Classification,
16
+ MediaType,
17
+ PlayoffCompetition,
18
+ PlayoffRound,
19
+ SeasonType,
20
+ )
21
+
22
+
23
+ class GamesRequest(BaseModel):
24
+ """Validate filters accepted by ``GET /games``.
25
+
26
+ :param year: Season year, required unless ``game_id`` is supplied.
27
+ :param week: Non-negative season week.
28
+ :param season_type: Season phase.
29
+ :param team: Team appearing on either side of the game.
30
+ :param home: Home-team selector.
31
+ :param away: Away-team selector.
32
+ :param conference: Conference selector.
33
+ :param classification: Division classification selector.
34
+ :param game_id: Positive game identifier serialized as upstream ``id``.
35
+ :param competition: Playoff competition selector.
36
+ :param round: Playoff round, requiring ``competition``.
37
+ """
38
+
39
+ model_config = ConfigDict(populate_by_name=True, extra="forbid")
40
+
41
+ year: int | None = Field(default=None, ge=1869)
42
+ week: int | None = Field(default=None, ge=0)
43
+ season_type: SeasonType | None = Field(default=None, alias="seasonType")
44
+ team: str | None = None
45
+ home: str | None = None
46
+ away: str | None = None
47
+ conference: str | None = None
48
+ classification: Classification | None = None
49
+ game_id: int | None = Field(default=None, gt=0, serialization_alias="id")
50
+ competition: PlayoffCompetition | None = None
51
+ round: PlayoffRound | None = None
52
+
53
+ @model_validator(mode="after")
54
+ def validate_selectors(self) -> Self:
55
+ """Validate year/game and playoff selector relationships.
56
+
57
+ :return: Validated request.
58
+ :raises ValueError: If required selectors are absent or incompatible.
59
+ """
60
+ _validate_year_or_game_id(self.year, self.game_id)
61
+ if self.round is not None and self.competition is None:
62
+ raise ValueError(
63
+ "competition parameter is required when round is specified"
64
+ )
65
+ if (
66
+ self.competition is PlayoffCompetition.cfp
67
+ and self.season_type is not None
68
+ and self.season_type not in {SeasonType.postseason, SeasonType.both}
69
+ ):
70
+ raise ValueError("CFP games are postseason games")
71
+ return self
72
+
73
+
74
+ class CalendarRequest(BaseModel):
75
+ """Validate filters accepted by ``GET /calendar``.
76
+
77
+ :param year: Required season year.
78
+ """
79
+
80
+ model_config = ConfigDict(populate_by_name=True, extra="forbid")
81
+
82
+ year: int = Field(ge=1869)
83
+
84
+
85
+ class RecordsRequest(BaseModel):
86
+ """Validate filters accepted by ``GET /records``.
87
+
88
+ :param year: Optional season year.
89
+ :param team: Optional team selector.
90
+ :param conference: Optional conference selector.
91
+ """
92
+
93
+ model_config = ConfigDict(populate_by_name=True, extra="forbid")
94
+
95
+ year: int | None = Field(default=None, ge=1869)
96
+ team: str | None = None
97
+ conference: str | None = None
98
+
99
+ @model_validator(mode="after")
100
+ def validate_year_or_team(self) -> Self:
101
+ """Require one of the two upstream record selectors.
102
+
103
+ :return: Validated request.
104
+ :raises ValueError: If neither ``year`` nor ``team`` is supplied.
105
+ """
106
+ _validate_at_least_one_of(
107
+ {"year": self.year, "team": self.team},
108
+ ("year", "team"),
109
+ )
110
+ return self
111
+
112
+
113
+ class ScoreboardRequest(BaseModel):
114
+ """Validate filters accepted by ``GET /scoreboard``.
115
+
116
+ Omitting ``classification`` preserves the upstream ``fbs`` default.
117
+
118
+ :param classification: Optional division classification selector.
119
+ :param conference: Optional conference name or abbreviation.
120
+ """
121
+
122
+ model_config = ConfigDict(populate_by_name=True, extra="forbid")
123
+
124
+ classification: Classification | None = None
125
+ conference: str | None = None
126
+
127
+
128
+ class GameMediaRequest(BaseModel):
129
+ """Validate filters accepted by ``GET /games/media``.
130
+
131
+ :param year: Required season year.
132
+ :param week: Optional non-negative season week.
133
+ :param season_type: Optional season phase.
134
+ :param team: Optional team selector.
135
+ :param conference: Optional conference selector.
136
+ :param media_type: Optional broadcast-medium selector.
137
+ :param classification: Optional division classification selector.
138
+ """
139
+
140
+ model_config = ConfigDict(populate_by_name=True, extra="forbid")
141
+
142
+ year: int = Field(ge=1869)
143
+ week: int | None = Field(default=None, ge=0)
144
+ season_type: SeasonType | None = Field(default=None, alias="seasonType")
145
+ team: str | None = None
146
+ conference: str | None = None
147
+ media_type: MediaType | None = Field(default=None, alias="mediaType")
148
+ classification: Classification | None = None
149
+
150
+
151
+ class GameWeatherRequest(BaseModel):
152
+ """Validate filters accepted by ``GET /games/weather``.
153
+
154
+ :param game_id: Positive game identifier serialized as upstream ``gameId``.
155
+ :param year: Season year, required unless ``game_id`` is supplied.
156
+ :param week: Optional non-negative season week.
157
+ :param season_type: Optional season phase.
158
+ :param team: Optional team selector.
159
+ :param conference: Optional conference selector.
160
+ :param classification: Optional division classification selector.
161
+ """
162
+
163
+ model_config = ConfigDict(populate_by_name=True, extra="forbid")
164
+
165
+ game_id: int | None = Field(default=None, gt=0, serialization_alias="gameId")
166
+ year: int | None = Field(default=None, ge=1869)
167
+ week: int | None = Field(default=None, ge=0)
168
+ season_type: SeasonType | None = Field(default=None, alias="seasonType")
169
+ team: str | None = None
170
+ conference: str | None = None
171
+ classification: Classification | None = None
172
+
173
+ @model_validator(mode="after")
174
+ def validate_weather_requirements(self) -> Self:
175
+ """Require a year when no game ID selects one game.
176
+
177
+ :return: Validated request.
178
+ :raises ValueError: If both ``game_id`` and ``year`` are absent.
179
+ """
180
+ if self.game_id is None and self.year is None:
181
+ raise ValueError("year is required when game_id is not specified")
182
+ return self
183
+
184
+
185
+ class PlayerGameStatsRequest(BaseModel):
186
+ """Validate filters accepted by ``GET /games/players``.
187
+
188
+ :param year: Season year used for a grouped selector.
189
+ :param week: Optional non-negative season week.
190
+ :param season_type: Optional season phase.
191
+ :param team: Optional team selector.
192
+ :param conference: Optional conference selector.
193
+ :param category: Optional player-stat category.
194
+ :param game_id: Positive game identifier serialized as upstream ``id``.
195
+ :param classification: Optional division classification selector.
196
+ """
197
+
198
+ model_config = ConfigDict(populate_by_name=True, extra="forbid")
199
+
200
+ year: int | None = Field(default=None, ge=1869)
201
+ week: int | None = Field(default=None, ge=0)
202
+ season_type: SeasonType | None = Field(default=None, alias="seasonType")
203
+ team: str | None = None
204
+ conference: str | None = None
205
+ category: str | None = None
206
+ game_id: int | None = Field(default=None, gt=0, serialization_alias="id")
207
+ classification: Classification | None = None
208
+
209
+ @model_validator(mode="after")
210
+ def validate_player_stats_requirements(self) -> Self:
211
+ """Validate the game-ID or grouped-selector alternatives.
212
+
213
+ :return: Validated request.
214
+ :raises ValueError: If the grouped selector is incomplete.
215
+ """
216
+ _validate_game_stats_selectors(
217
+ self.year, self.week, self.team, self.conference, self.game_id
218
+ )
219
+ return self
220
+
221
+
222
+ class TeamGameStatsRequest(BaseModel):
223
+ """Validate filters accepted by ``GET /games/teams``.
224
+
225
+ :param year: Season year used for a grouped selector.
226
+ :param week: Optional non-negative season week.
227
+ :param season_type: Optional season phase.
228
+ :param team: Optional team selector.
229
+ :param conference: Optional conference selector.
230
+ :param game_id: Positive game identifier serialized as upstream ``id``.
231
+ :param classification: Optional division classification selector.
232
+ """
233
+
234
+ model_config = ConfigDict(populate_by_name=True, extra="forbid")
235
+
236
+ year: int | None = Field(default=None, ge=1869)
237
+ week: int | None = Field(default=None, ge=0)
238
+ season_type: SeasonType | None = Field(default=None, alias="seasonType")
239
+ team: str | None = None
240
+ conference: str | None = None
241
+ game_id: int | None = Field(default=None, gt=0, serialization_alias="id")
242
+ classification: Classification | None = None
243
+
244
+ @model_validator(mode="after")
245
+ def validate_team_stats_requirements(self) -> Self:
246
+ """Validate the game-ID or grouped-selector alternatives.
247
+
248
+ :return: Validated request.
249
+ :raises ValueError: If the grouped selector is incomplete.
250
+ """
251
+ _validate_game_stats_selectors(
252
+ self.year, self.week, self.team, self.conference, self.game_id
253
+ )
254
+ return self
255
+
256
+
257
+ class AdvancedBoxScoreRequest(BaseModel):
258
+ """Validate filters accepted by ``GET /game/box/advanced``.
259
+
260
+ :param game_id: Required positive game identifier serialized as upstream
261
+ ``id``.
262
+ """
263
+
264
+ model_config = ConfigDict(populate_by_name=True, extra="forbid")
265
+
266
+ game_id: int = Field(gt=0, serialization_alias="id")