supercontest.util.types

Collection of custom types, classes, aliases, and generics used by other modules.

Module Attributes

PickCounts

Pick counts.

PickCountsByUser

Pick counts, by user.

PickCountsByUserByWeek

Pick counts, by user, by week.

PickCountsByUserByWeekBySeason

Pick counts, by user, by week, by season.

PickCountsByWeek

Pick counts, by week.

PickCountsByWeekByUser

Pick counts, by week, by user.

PickCountsBySeason

Pick counts, by season.

PickCountsBySeasonByUser

Pick counts, by season, by user.

PointRollups

Point rollups.

PointRollupsByUser

Point rollups, by user.

PointRollupsByUserByWeek

Point rollups, by user, by week.

PointRollupsByUserByWeekBySeason

Point rollups, by user, by week, by season.

PointRollupsByWeek

Point rollups, by week.

PointRollupsByWeekByUser

Point rollups, by week, by user.

PointRollupsBySeason

Point rollups, by season.

PointRollupsBySeasonByUser

Point rollups, by season, by user.

RawPicksByUser

Picks, by user.

RawPicksByUserByWeek

Picks, by user, by week.

RawPicksByUserByWeekBySeason

Picks, by user, by week, by season.

Functions

ddict2dict

Converts a defaultdict to a dict.

Classes

AlltimeResults

Typing for single-row (user) results of an ALLTIME-scoped view.

Line

One game's line, as the lines job commits it, from either source.

LinesFetch

One game as Westgate's card prints it: text, before anything is read into it.

ScoresFetch

Keys and their types for the fetched scores dictionary.

SeasonResults

Typing for single-row (user) results of a SEASON-scoped view.

WeekResultRow

One user's week: picks, points so far, rank, and grade.

WeekResults

Typing for single-row (user) results of a WEEK-scoped view.

class supercontest.util.types.AlltimeResults

Bases: TypedDict

Typing for single-row (user) results of an ALLTIME-scoped view.

avg_pick_margin: NotRequired[int | float]
cover: int
noncover: int
num_picks: int
percentage: int | float
pick_counts_by_season: dict[int, dict[str, int]]
point_rollups_by_season: dict[int, dict[str, float]]
points: int | float
push: int
rank: NotRequired[int]
user_id: int
class supercontest.util.types.Line(kickoff: datetime, line: float, favored_team: str, underdog_team: str, home_team: str | None)

Bases: object

One game’s line, as the lines job commits it, from either source.

The card and the admin’s hand-entered lines both become this before commit_lines sees them, so nothing turns a typed time back into Westgate’s text to have it parsed again.

favored_team: str
classmethod from_fetch(fetch: LinesFetch) → Line

Reads a card’s printed game.

Parameters:

fetch – The parser’s text.

Returns:

The line.

Raises:

ValueError – If the kickoff or the line is not what the card prints.

home_team: str | None

One of the two teams, or None for a neutral site.

kickoff: datetime

The kickoff, aware, in UTC.

line: float

Points the favorite gives; 0 for a pick’em.

underdog_team: str
class supercontest.util.types.LinesFetch

Bases: TypedDict

One game as Westgate’s card prints it: text, before anything is read into it.

The PDF parser’s output. Line.from_fetch() reads it into a Line at the edge; nothing past the fetch sees this shape.

datetime: str
favored_team: str
home_team: str | None
line: str
underdog_team: str
supercontest.util.types.PickCounts

Pick counts.

alias of defaultdict[str, int]

supercontest.util.types.PickCountsBySeason

Pick counts, by season.

alias of dict[int, dict[str, int]]

supercontest.util.types.PickCountsBySeasonByUser

Pick counts, by season, by user.

alias of defaultdict[int, dict[int, dict[str, int]]]

supercontest.util.types.PickCountsByUser

Pick counts, by user.

alias of defaultdict[int, defaultdict[str, int]]

supercontest.util.types.PickCountsByUserByWeek

Pick counts, by user, by week.

alias of defaultdict[int, defaultdict[int, defaultdict[str, int]]]

supercontest.util.types.PickCountsByUserByWeekBySeason

Pick counts, by user, by week, by season.

alias of defaultdict[int, defaultdict[int, defaultdict[int, defaultdict[str, int]]]]

supercontest.util.types.PickCountsByWeek

Pick counts, by week.

alias of dict[int, defaultdict[str, int]]

supercontest.util.types.PickCountsByWeekByUser

Pick counts, by week, by user.

alias of defaultdict[int, dict[int, defaultdict[str, int]]]

supercontest.util.types.PointRollups

Point rollups.

alias of defaultdict[str, float]

supercontest.util.types.PointRollupsBySeason

Point rollups, by season.

alias of dict[int, dict[str, float]]

supercontest.util.types.PointRollupsBySeasonByUser

Point rollups, by season, by user.

alias of defaultdict[int, dict[int, dict[str, float]]]

supercontest.util.types.PointRollupsByUser

Point rollups, by user.

alias of defaultdict[int, defaultdict[str, float]]

supercontest.util.types.PointRollupsByUserByWeek

Point rollups, by user, by week.

alias of defaultdict[int, defaultdict[int, defaultdict[str, float]]]

supercontest.util.types.PointRollupsByUserByWeekBySeason

Point rollups, by user, by week, by season.

alias of defaultdict[int, defaultdict[int, defaultdict[int, defaultdict[str, float]]]]

supercontest.util.types.PointRollupsByWeek

Point rollups, by week.

alias of dict[int, defaultdict[str, float]]

supercontest.util.types.PointRollupsByWeekByUser

Point rollups, by week, by user.

alias of defaultdict[int, dict[int, defaultdict[str, float]]]

supercontest.util.types.RawPicksByUser

Picks, by user.

alias of defaultdict[int, list[Any]]

supercontest.util.types.RawPicksByUserByWeek

Picks, by user, by week.

alias of defaultdict[int, defaultdict[int, list[Any]]]

supercontest.util.types.RawPicksByUserByWeekBySeason

Picks, by user, by week, by season.

alias of defaultdict[int, defaultdict[int, defaultdict[int, list[Any]]]]

class supercontest.util.types.ScoresFetch

Bases: TypedDict

Keys and their types for the fetched scores dictionary.

status: str
team_scores: dict[str, int]
class supercontest.util.types.SeasonResults

Bases: TypedDict

Typing for single-row (user) results of a SEASON-scoped view.

bonus: NotRequired[int]
cover: int
noncover: int
num_picks: int
payout: NotRequired[int]
percentage: int | float
percentile: NotRequired[int | float]
pick_counts_by_week: dict[int, defaultdict[str, int]]
point_rollups_by_week: dict[int, defaultdict[str, float]]
points: int | float
previous_rank: NotRequired[int | None]
purse: NotRequired[int]
push: int
rank: NotRequired[int]
user_id: int
class supercontest.util.types.WeekResultRow

Bases: WeekResults

One user’s week: picks, points so far, rank, and grade.

grade: NotRequired[float]
name: str
num_picks: int
pick_counts: defaultdict[str, int]
points_finished: float
points_inprogress: float
rank: NotRequired[int]
sorted_pick_teams: list[str]
user_id: int
class supercontest.util.types.WeekResults

Bases: TypedDict

Typing for single-row (user) results of a WEEK-scoped view.

grade: NotRequired[float]
num_picks: int
pick_counts: defaultdict[str, int]
points_finished: float
points_inprogress: float
rank: NotRequired[int]
sorted_pick_teams: list[str]
user_id: int
supercontest.util.types.ddict2dict(ddict: defaultdict[Any, Any] | dict[Any, Any]) → dict[Any, Any]

Converts a defaultdict to a dict. Handles nested/recursion.

Parameters:

ddict – Default dictionary.

Returns:

Dictionary.