I am monkey-patching a class from a 3rd party library (playwright in my case) and also want to adjust the type hinting to include my adjustment. Is there a way somehow to overwrite or augment types from 3rd party libraries?
##
# Monkey-patching
##
from playwright.sync_api import Locator
def poll(self): # my custom function
pass
# type error: poll is unknown
Locator.poll = poll
##
# Usage
##
def test_succeeds(page: Page):
...
# type error: poll is unknown
expect(page.locator('dl:has-text("Success")').poll()).to_be_visible()