Fix _codecs.escape_decode return type by ledvinap · Pull Request #15531 · python/typeshed
Summary
Fix the stdlib stub for _codecs.escape_decode so it returns tuple[bytes, int] instead of tuple[str, int].
Also add regression coverage in stdlib/@tests/test_cases/check_codecs.py to verify the inferred return type for codecs.escape_decode.
Details
Python's docs describe codecs.escape_decode as returning bytes, and CPython runtime behavior matches that. The old stub returned str, which then propagated
to codecs.escape_decode because codecs.pyi re-exports _codecs.
I kept the input type as str | ReadableBuffer rather than narrowing it to bytes-like only, because current CPython still accepts str input at runtime and
returns (bytes, int).
AI assistance
This PR was prepared by OpenAI Codex/GPT-5 and is human-validated.