Skip to content

Pass keyword arguments to Handlers' callbacks and other interfaces (breaks backward compatibility!) #291

@cztomczak

Description

@cztomczak

Since upstream CEF constantly changes, to minimize code breaking when updating to newer CEF, it would be best to use keyword arguments in callbacks, so that when a new argument is added it will not break existing code. And when argument is removed in upstream CEF, we might still keep the old argument for BC.

Using keyword arguments would also be useful in PyCharm so that it doesn't generate warnings when there are unused parameters in callbacks.

For example a callback would be defined like this:

def OnLoadStart(self, **kwargs):
    browser = kwargs["browser"]    

or:

def OnLoadStart(self, browser, **_):
    pass

To make this possible, src/handlers/ need to be modified, so that keyword arguments are specified when calling user-provided callback.

This will break existing code! So changes will be required.

There is also a related feature to catch possible errors in parameters when declaring Handlers - Issue #215 "Expose handlers as classes/interfaces: ClientHandler, DisplayHandler, LifespanHandler, etc.". This feature does not conflict with using **kwargs, there would just be two ways for doing it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions