← Back to microsoft/playwright
microsoft / playwright · Issue No. 42857
1.63.0
On Python 3.14+ execute the following minimal reproducer using pytest with pytest-playwright installed.
from playwright.sync_api import Page
def test_has_title(page: Page) -> None:
def callback(msg: Unresolvable) -> None:
pass
page.on('console', callback)
page.goto("https://playwright.dev/")
The given example passes without errors
NameError is emitted for Unresolved despite not being needed by playwright in order to function correctly.
The Python version makes use of inspect.signature to inspect the parameters of callbacks passed to methods like Page.on, but does not make use of the newly added format parameter in Python 3.14+, despite not needing to inspect the annotations.
It's best practice to use Format.FORWARDREF or Format.STRING if you don't need to inspect annotations, so the deferred execution of the annotations does not result in a NameError for any symbols only defined inside an if TYPE_CHECKING block.
I recommend writing a little compat helper like the following:
import inspect
import sys
if sys.version_info < (3, 14):
def get_signature(fn):
return inspect.signature(fn)
else:
from annotationlib import Format
def get_signature(fn):
return inspect.signature(fn, annotation_format=Format.FORWARDREF)
And using that instead of directly calling inspect.signature in the two places playwright currently uses it.
System:
OS: Linux 7.2 openSUSE Tumbleweed 20260915
CPU: (8) x64 AMD Ryzen 7 PRO 3700U w/ Radeon Vega Mobile Gfx
Memory: 8.13 GB / 21.38 GB
Container: Yes
Binaries:
Node: 24.18.1 - /usr/bin/node
npm: 2.15.12 - /home/david/git/onegov-cloud/node_modules/.bin/npm
Languages:
Bash: 5.3.15 - /usr/bin/bash
Relay reads this issue against the repository's contribution signals: the files it is likely to touch, how the maintainers triage work this size, and what the first contribution would exercise.
The full analysis for this issue is still being assembled. Until then, the description above and the thread on GitHub are the most reliable context.