feat(baseball): expanded API coverage - Transactions, RotoBoxScore, stats splits... - #691
Merged
Merged
Conversation
- Settings class exposes position_slot_counts from rosterSettings - Transaction/TransactionItem classes model ESPN transaction API responses - League.transactions() fetches waiver/FA/trade activity for a scoring period - League.player_info() looks up a player by name or ID - League.refresh() updates league state without re-fetching all players - League.load_roster_week() loads team rosters for a historical week - League._fetch_league() now passes Settings as SettingsClass
- Add DEFAULT_POSITION_MAP for player.position (separate from lineupSlot) - Add baseball Settings class with position_slot_counts - Add Transaction / TransactionItem classes with League.transactions() method - Expand Player with ownership, draft ranks, keeper/lock flags, news date, etc. - Expand Team with split records, streak, projected/waiver rank - Expand BaseSettings with acquisition limits, waiver settings, trade revision hours - Remove debug pdb imports from matchup.py and team.py - Add unit tests for Player, Settings, Transaction, Team
Adds STAT_SPLIT_MAP and player.stats_splits dict keyed by split label (season, last_7, last_15, last_30, box_score). player.stats and total_points remain unchanged for backwards compatibility.
…tems - Switch view from kona_league_transactions to mTransactions2 - Default items to [] for transaction types that carry no items (e.g. TRADE_DECLINE)
- transactions(): tighten type hint from set to Set[str] - Player: convert acquisitionDate to datetime (consistent with last_news_date) - Player: use explicit key check for playerPoolEntry fallback - Player: log warning for unknown statSplitTypeId instead of silently dropping - Transaction: store team_id; guard __repr__ against None team
Add tests for BaseSettings core fields, Player.proTeam/total_points/ eligibleSlots/__repr__, Transaction optional fields (bid_amount, comment, memberId, types filter header), TransactionItem.__repr__, and League.standings() sort behaviour.
- Use ValueError instead of Exception in transactions() type validation - Copy waiver_process_days list to prevent external mutation of settings - Add type hints to Transaction.__init__ callback parameter - Add comments on millisecond timestamp conversions, intentional stat split filtering, position slot exclusions, and -1 projected sentinel
- Normalize Transaction/TransactionItem fields to snake_case and use None defaults for comment and member_id - Make RotoBoxScore inherit from BoxScore with None stubs for winner/home_team/away_team so isinstance checks work uniformly - Fix box_scores() return type hint to List[BoxScore] and document the four concrete shapes - Use `in` membership tests in Player stats_splits population to handle present-but-empty buckets safely - Add comment explaining ESPN's 'Infinity' string for zero-denominator rate stats in RotoBoxScore
Fixes pitcher stats showing batter stats (e.g. '1B', 'SB-CS') by filtering based on position eligibility. Handles multi-position players like Ohtani who are eligible for both pitcher and batter slots.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #691 +/- ##
==========================================
+ Coverage 71.09% 75.07% +3.98%
==========================================
Files 62 64 +2
Lines 2425 2616 +191
==========================================
+ Hits 1724 1964 +240
+ Misses 701 652 -49 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Guard the name→playerId reassignment on player_map membership so an explicit playerId survives an unknown name. Also lift inline pitcher/batter slot sets to PITCHER_POSITIONS / BATTER_POSITIONS constants and compute eligibility flags once per Player.
gdifiore
marked this pull request as ready for review
April 19, 2026 19:58
|
Would love to see these features. |
Contributor
Author
|
Sorry for all the changes @cwendt94, I can split this into multiple PRs if you prefer. Just kinda how I ended up testing it all |
Owner
|
This is great, thanks for all the feature updates and tests! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary