Skip to content

fix(handlers): do not evaluate handler annotations in inspect.signature on Python 3.14 - #3204

Open
Ashraf Ali (ashrafiucse) wants to merge 1 commit into
microsoft:mainfrom
ashrafiucse:fix-42857
Open

Ashraf Ali (ashrafiucse) wants to merge 1 commit into
microsoft:mainfrom
ashrafiucse:fix-42857

Conversation

@ashrafiucse

Copy link
Copy Markdown

Summary

  • On Python 3.14, inspect.signature() evaluates the lazily-computed annotations (PEP 649/749) by default, so event listeners and locator handlers annotated with names that only exist under if TYPE_CHECKING: raised NameError when Playwright inspected the handler signature — even though only the parameter list is used.
  • Add a small signature() compat helper that passes annotation_format=Format.FORWARDREF on Python 3.14+ and is a plain inspect.signature() on older versions, and use it at the two call sites (wrap_handler, LocatorHandler.__call__).
  • Regression tests for both paths (event listener + locator handler) in async and sync suites, gated to 3.14+.

Fixes microsoft/playwright#42857

…re on Python 3.14

Since PEP 649 (Python 3.14), annotations are lazily evaluated and
inspect.signature() resolves them eagerly by default. Event listeners
and locator handlers annotated with names that only exist under
`if TYPE_CHECKING:` therefore raised NameError when the signature was
inspected, even though only the parameter list is needed. Ask for
unresolved forward references instead.

Fixes: microsoft/playwright#42857

This branch has not been deployed

No deployments
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]: The Python version of Playwright is not compatible with PEP-749/PEP-649 annotation semantics

1 participant