Skip to content

fix(typing): typed overloads for expect_event and wait_for_event#3061

Open
dgozman wants to merge 2 commits intomicrosoft:mainfrom
dgozman:fix-3047
Open

fix(typing): typed overloads for expect_event and wait_for_event#3061
dgozman wants to merge 2 commits intomicrosoft:mainfrom
dgozman:fix-3047

Conversation

@dgozman
Copy link
Copy Markdown
Contributor

@dgozman dgozman commented Apr 30, 2026

Summary

  • Codegen now emits @typing.overload stubs for expect_event / wait_for_event keyed on Literal["event_name"] with the payload type from api.json, plus a catch-all event: str overload returning EventContextManager[Any] / Any.
  • info.value now narrows to the correct payload type (e.g. Request for expect_event("requestfinished")) instead of Any/Unknown under strict pyright.
  • Fixes a couple of latent test-side type slips that the new precise types exposed (ResourceTiming vs Dict, optional Error.stack).

Fixes #3047

Generates @typing.overload stubs keyed on Literal event names with their
payload types from api.json, so pyright/mypy can narrow the return type
at call sites instead of falling back to Any/Unknown.

Fixes: microsoft#3047
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.

[Bug]: Page.expect_event signature is missing generics

2 participants