Skip to content

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

Closed

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.

Activity

  1. changed the title [-]Pass keyword arguments to Handlers' callbacks[/-] [+]Pass keyword arguments to Handlers' callbacks and other interfaces[/+] on Dec 20, 2016
  2. changed the title [-]Pass keyword arguments to Handlers' callbacks and other interfaces[/-] [+]Pass keyword arguments to Handlers' callbacks and other interfaces (breaks backward compatibility!)[/+] on Dec 20, 2016
  3. cztomczak commented on Dec 20, 2016

    @cztomczak
    OwnerAuthor

    Done in commit 0a7d8d6. All examples and unit tests updated to use the new style.

  4. added this to the v55 milestone on Feb 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions