Skip to content

[BUG] Mypy Error with Playwright devices #795

@kumaraditya303

Description

@kumaraditya303

Consider the following snippet:

# main.py
from playwright.sync_api import Playwright, sync_playwright

def run(playwright: Playwright) -> None:
    pixel_2 = playwright.devices["Pixel 2"]
    browser = playwright.webkit.launch(headless=False)
    context = browser.new_context(
        **pixel_2,
    )
    page = context.new_page()
    page.goto("https://github.com")
    page.close()


with sync_playwright() as playwright:
    run(playwright)

Run mypy check on the file with:

mypy main.py --strict --disallow-any-expr

It errors out with error:

mypy main.py --strict --disallow-any-expr
main.py:5: error: Expression type contains "Any" (has type "Dict[Any, Any]")
main.py:5: error: Expression has type "Any"     
main.py:8: error: Expression has type "Any"     
Found 3 errors in 1 file (checked 1 source file)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions