Skip to content

feat: make strict HTTP behavior the default (#284) - #291

Merged
Mattsface merged 1 commit into
release/1.0.0from
feat/v1-strict-http-default
Aug 5, 2026
Merged

feat: make strict HTTP behavior the default (#284)#291
Mattsface merged 1 commit into
release/1.0.0from
feat/v1-strict-http-default

Conversation

@Mattsface

@Mattsface Mattsface commented Aug 5, 2026

Copy link
Copy Markdown
Member

Closes #284

Parent release issue: #282
Depends on: #283 (merged via #290 / 94d944f)

Why the default changes

Version 1.0 makes strict HTTP the production default so Mlb() and MlbDataAdapter() raise MlbHttpError for final non-404 4xx responses instead of returning historical empty results. Compatibility mode remains available via explicit strict_http=False.

Production files changed

  • mlbstatsapi/mlb_api.pystrict_http: bool = True (keyword-only); value still forwarded to _mlb_adapter_v1 and _mlb_adapter_v1_1
  • mlbstatsapi/mlb_dataadapter.pystrict_http: bool = True (keyword-only); response decision logic unchanged

How explicit compatibility mode is preserved

strict_http=False continues to:

  • return the historical empty MlbResult for final non-404 4xx
  • emit MlbHttpCompatibilityWarning
  • preserve endpoint-specific 404 shapes
  • raise MlbHttpError for final 5xx

Warning text and stacklevel are intentionally unchanged (owned by #285).

Confirmation that 404 behavior remains unchanged

In both modes, 404 still returns an MlbResult for endpoint-level handling:

  • get_person()None
  • get_teams()[]
  • get_player_stats(){}

A 404 does not become MlbHttpError.

The test-helper correction

tests/http_contract_support.standalone_adapter_for_version (and the local retry harness helper) now use a private _UNSET sentinel so omitted strict_http truly omits the constructor argument. Explicit True / False still pass through.

Which #284 xfails were removed

Removed XFAIL_PENDING_STRICT_DEFAULT / Pending #284 from:

  • test_mlb_default_matches_explicit_strict_mode_wiring
  • test_mlb_data_adapter_default_is_strict
  • test_default_adapter_raises_on_final_non_404_client_error
  • test_default_mlb_raises_on_final_non_404_client_error
  • test_final_429_raises_mlb_http_error_after_retry_exhaustion_default_adapter
  • test_final_429_raises_via_default_mlb_client_after_retry_exhaustion

Also updated constructor-default assertions and non-retryable client-error expectations for the new default.

Focused test results

poetry run pytest \
  tests/test_http_contract.py \
  tests/test_http_warnings.py \
  tests/test_mlb_retries.py \
  tests/test_mlb_session.py \
  -v -rxX

299 passed, 1 xfailed

Full offline-suite results

poetry run pytest tests/ --ignore=tests/external_tests -v -rxX

432 passed, 1 xfailed

poetry check succeeded (existing Poetry config deprecation warnings only).
git diff --check clean.

Remaining xfails and their associated issues

  • XFAIL_PENDING_WARNING_CALL_SITE / Pending #285test_compatibility_warning_points_to_public_mlb_endpoint_caller_line

Risk assessment

Intentionally left out

  • No README, migration-guide, or release-note updates
  • No package version bump
  • No warning message / stacklevel changes
  • No retry, timeout, or Session ownership changes
Open in Web Open in Cursor 

Co-authored-by: Matthew Spah <spahmatthew@gmail.com>
@Mattsface
Mattsface marked this pull request as ready for review August 5, 2026 21:28

@Mattsface Mattsface left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants