Skip to content
Commit Detail

Commit 03281a0

Author
Hood Chatham <roberthoodchatham@gmail.com> 2025-08-25 10:29:39 +0200
Parents
8b4e2bc
Tree
9ac57a3
Python: `Response`: Handle instance json method (#4867)

The JavaScript `json` method is both a static method and an instance method
on `Response`. Doing this in Python is awkward and doesn't work correctly
with static type checkers. To maintain compatibility, I made `json()` work
at runtime as a static method or an instance method. It will only type check
when used as an instance method.

I added a new `from_json()` method which is static only and will work as
expected with mypy.

I also made as many places as possible return Response instead of FetchResponse.

Files changed

2 files changed~2 modified