Releases: zero-sum-seattle/python-mlb-statsapi
v0.7.1
Release Notes v0.7.1
🎉 Major Changes
Removed Key Transformation Layer
Removed the _transform_keys_in_data() function that was lowercasing all API response keys. Models now directly use the MLB Stats API's native camelCase format, simplifying the codebase and ensuring accurate representation of API responses.
Complete Pydantic Migration
This release includes the complete migration from Python dataclasses to Pydantic v2 models across the entire codebase (from v0.7.1). All models now use Pydantic for validation, serialization, and data handling.
Key Benefits:
- Automatic data validation with clear error messages
- Built-in serialization with
model_dump()andmodel_dump_json() - Pythonic
snake_casefield names while maintaining APIcamelCasecompatibility - Better type safety and IDE support
📝 Breaking Changes
-
Field Access: All model fields now use
snake_caseinstead ofcamelCase:# Before game.gamedata.weather # After game.game_data.weather
-
Validation Errors: Invalid data now raises
pydantic.ValidationErrorinstead ofTypeError -
Serialization: Use Pydantic methods for serialization:
# New methods model.model_dump() model.model_dump_json()
🔧 Model Updates
Core Models
- All models migrated to Pydantic
MLBBaseModel - Field aliases updated to match actual API
camelCaseformat - Optional fields properly marked for fields that may be missing
Specific Model Fixes
- Game Models:
gamePk,gameData,liveData,metaDataaliases corrected - HomeRunDerby:
homeRun,tieBreaker,isHomeRun,isTieBreakeraliases fixed - Stats Models:
wobaCon,pitchArsenalaliases corrected - Schedule Models:
calendarEventIdmade optional - Standings Models:
wildcardGamesBack,wildcardEliminationNumbermade optional
🐛 Bug Fixes
- Fixed missing fields in various stat models
- Added
ageandcaughtstealingpercentagetoSimplePitchingSplit - Fixed
flyballpercentagefield inAdvancedPitchingSplit - Updated models for new MLB API fields
- Fixed missing keys in live feed data
📚 Documentation
- Updated README with Pydantic migration examples
- Added "Working with Pydantic Models" section
- Added Contributing section to README
- Updated all code examples to use
snake_casefield names
🔄 Migration Guide
If you're upgrading from v0.5.x or v0.6.x:
-
Update field access: Change all
camelCasefield names tosnake_case# Old game.gamedata.weather stat.totalsplits # New game.game_data.weather stat.total_splits
-
Update error handling: Catch
ValidationErrorinstead ofTypeErrorfrom pydantic import ValidationError try: game = Game(**data) except ValidationError as e: # Handle validation error
-
Use Pydantic serialization: Replace
__dict__access withmodel_dump()# Old data = game.__dict__ # New data = game.model_dump()
📦 Dependencies
- Added
pydantic>=2.0as a core dependency - Migrated from setuptools to Poetry for dependency management
🧪 Testing
- Removed all mock tests (22,370+ lines)
- External tests updated and passing
- CI/CD pipelines updated to remove mock test runs
Full Changelog: v0.5.3...v0.7.0