feat: preserve explicit HTTP compatibility mode (#285) - #292
Merged
Conversation
Co-authored-by: Matthew Spah <spahmatthew@gmail.com>
cursor
Bot
force-pushed
the
feat/v1-compatibility-mode
branch
from
August 5, 2026 21:32
e8455d9 to
5c27e4c
Compare
Mattsface
marked this pull request as ready for review
August 5, 2026 21:36
This was referenced Aug 6, 2026
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.
Closes #285
Why compatibility mode remains available
Version 1.0 makes strict HTTP handling the default (#284), but callers who explicitly construct
Mlb(strict_http=False)orMlbDataAdapter(strict_http=False)must keep the historical empty-result behavior for final non-404 4xx responses. This preserves an intentional opt-in escape hatch without changing the new default.Why the warning wording changed
The 0.9 wording said compatibility behavior “may change in version 1.0,” which is no longer accurate once 1.0 ships. The warning now states that:
strict_http=Falsestrict_http=Falseor passingstrict_http=TrueraisesMlbHttpErrorOnly the status code and resolved request URL are included from the response. Response bodies, headers, credentials, cookies, and tokens are never included.
Why a fixed stack level was insufficient
COMPATIBILITY_WARNING_STACKLEVEL = 3correctly pointed at directadapter.get()callers, but for publicMlbendpoint methods the same fixed depth landed on the internalmlbstatsapi/mlb_api.pyframe (for exampleget_personat line 178) instead of the application call site.How the external caller frame is selected
A private
_compatibility_warning_stacklevel()helper walksinspect.currentframe()parents and returns the firstwarnings.warn()stack level whose module is outside themlbstatsapi/mlbstatsapi.*namespace. This works for both direct adapter calls and publicMlbendpoint wrappers without hard-coding endpoint methods or relying on Python 3.12-only warning APIs.Confirmations
strict_http=Trueafter rebasing onto Make strict HTTP behavior the default in 1.0 #284; this PR does not change defaults#285 xfail removed
XFAIL_PENDING_WARNING_CALL_SITEfromtests/http_contract_support.pytests/test_http_warnings.pyrg "XFAIL_PENDING_WARNING_CALL_SITE|Pending #285" testsreturns no matchesFocused test results (after rebase onto #284)
300 passed, 0 failed, 0 xfailed
Caller-location tests:
test_compatibility_warning_points_to_direct_adapter_caller_line— passedtest_compatibility_warning_points_to_public_mlb_endpoint_caller_line— passedFull offline-suite results (after rebase)
433 passed, 0 failed, 0 xfailed
Remaining xfails and their issue numbers
None after rebasing onto merged #284. Previously pending
#284xfails are gone fromrelease/1.0.0.Rebase status relative to #284
Rebased onto
origin/release/1.0.0after #291 (feat: make strict HTTP behavior the default (#284)) merged. Clean rebase with no conflicts. Production defaults remain:Compatibility tests continue to use explicit
strict_http=False.Risk assessment
Low. Changes are confined to compatibility-warning message text and stack-level calculation, plus activating the existing #285 contract test. Public return shapes, exception hierarchy, retry policy, Session ownership, and constructor defaults are unchanged.