New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Improvement] "Unresolved attribute reference 'stop' for classes SyncPlaywrightContextManager/ AsyncPlaywrightContextManager appears in IDE #179
Comments
Could you share with us the exact snippet which is causing that error? And which IDE are you using? |
PyCharm
when later is needed to use sync_plw.stop() ---> stop method is not listed by IDE among available methods. |
The usage is a bit different, see this example: from playwright import sync_playwright
playwright = sync_playwright().start()
for browser_type in [playwright.chromium, playwright.firefox, playwright.webkit]:
browser = browser_type.launch()
page = browser.newPage()
page.goto("http://whatsmyuseragent.org/")
page.screenshot(path=f"example-{browser_type.name}.png")
browser.close()
playwright.stop() |
thanks, I saw it before creation of this improvement ). |
Then I close it okay? |
of course, you can. My purpose was if I can control an instance of a context manager with the start method, why I need to use |
So we internally start a driver which is basically the upstream github.com/microsoft/playwright project under the hood. In the upstream package the magic happens and in the Python world we only call the Node.js methods internally with a custom JSON based protocol over stdin/stdout. |
When to use "REPL support without context managers", IDE shows inspection warning "Unresolved attribute reference 'stop' for classes SyncPlaywrightContextManager (for Async too).
It's because stop is registered not obviously, e.g. in line 96: playwright.stop = self.exit # type: ignore
It's better to implement the same solution for stop() as with start()
OR
if to change e.g. in SyncPlaywrightContextManager:
the 'Unresolved attribute reference' inspection in IDE will be fixed and everything will work as expected.
The same changes may be applied for Async for start/stop.
The text was updated successfully, but these errors were encountered: