Repository: servo/servo
File: tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservodriver.py (Python)

Code before:
def do_delayed_imports():
    global webdriver
    import webdriver

    global ServoCommandExtensions

    class ServoCommandExtensions:
        def __init__(self, session):
            self.session = session

        def get_prefs(self, *prefs):
            body = {"prefs": list(prefs)}
            return self.session.send_session_command("GET", "servo/prefs/get", body)

        def set_prefs(self, prefs):
            body = {"prefs": prefs}
            return self.session.send_session_command("POST", "servo/prefs/set", body)

        def reset_prefs(self, *prefs):
            body = {"prefs": list(prefs)}
            return self.session.send_session_command("POST", "servo/prefs/reset", body)
        
        def shutdown(self):
            body = {}
            return self.session.send_session_command("DELETE", "servo/shutdown", body)
        

        def change_prefs(self, old_prefs, new_prefs):
            # Servo interprets reset with an empty list as reset everything
            if old_prefs:
                self.reset_prefs(*old_prefs.keys())
            self.set_prefs({k: parse_pref_value(v) for k, v in new_prefs.items()})


# See parse_pref_from_command_line() in components/config/opts.rs
def parse_pref_value(value):
    if value == "true":
        return True
    if value == "false":
        return False
    try:
        return float(value)
    except ValueError:
        return value


class ServoWebDriverProtocol(WebDriverProtocol):
    def __init__(self, executor, browser, capabilities, **kwargs):
        do_delayed_imports()
        WebDriverProtocol.__init__(self, executor, browser, capabilities, **kwargs)


Review comment (bug):
```
./wptrunner/wptrunner/executors/executorservodriver.py:34:1: W293 blank line contains whitespace
./wptrunner/wptrunner/executors/executorservodriver.py:38:1: W293 blank line contains whitespace
```
Per the CI failures in https://community-tc.services.mozilla.com/tasks/FisJG5vlTpqDDj8LB1U-Iw/runs/0/logs/live/public/logs/live.log

Code after:
def do_delayed_imports():
    global webdriver
    import webdriver

    global ServoCommandExtensions

    class ServoCommandExtensions:
        def __init__(self, session):
            self.session = session

        def get_prefs(self, *prefs):
            body = {"prefs": list(prefs)}
            return self.session.send_session_command("GET", "servo/prefs/get", body)

        def set_prefs(self, prefs):
            body = {"prefs": prefs}
            return self.session.send_session_command("POST", "servo/prefs/set", body)

        def reset_prefs(self, *prefs):
            body = {"prefs": list(prefs)}
            return self.session.send_session_command("POST", "servo/prefs/reset", body)

        def shutdown(self):
            body = {}
            return self.session.send_session_command("DELETE", "servo/shutdown", body)


        def change_prefs(self, old_prefs, new_prefs):
            # Servo interprets reset with an empty list as reset everything
            if old_prefs:
                self.reset_prefs(*old_prefs.keys())
            self.set_prefs({k: parse_pref_value(v) for k, v in new_prefs.items()})


# See parse_pref_from_command_line() in components/config/opts.rs
def parse_pref_value(value):
    if value == "true":
        return True
    if value == "false":
        return False
    try:
        return float(value)
    except ValueError:
        return value


class ServoWebDriverProtocol(WebDriverProtocol):
    def __init__(self, executor, browser, capabilities, **kwargs):
        do_delayed_imports()
        WebDriverProtocol.__init__(self, executor, browser, capabilities, **kwargs)