Skip to content

Commit b8390b8

Browse files
typing
1 parent 3864da8 commit b8390b8

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

tools/webdriver/webdriver/bidi/protocol.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ class BidiValue(ABC):
1010
protocol_value: Dict[str, Any]
1111
type: str
1212

13-
def __init__(self, protocol_value):
13+
def __init__(self, protocol_value: Dict[str, Any]):
1414
assert isinstance(protocol_value, dict)
1515
assert isinstance(protocol_value["type"], str)
1616
self.type = protocol_value["type"]
1717
self.protocol_value = protocol_value
1818

19-
def to_classic_protocol_value(self) -> Dict:
19+
def to_classic_protocol_value(self) -> Dict[str, Any]:
2020
"""Convert the BiDi value to the classic protocol value. Required for compatibility of the values sent over BiDi
2121
transport with the classic actions."""
2222
raise NotImplementedError("No conversion to the classic protocol value is implemented.")
@@ -30,7 +30,7 @@ def __init__(self, protocol_value: Dict[str, Any]):
3030
assert self.type == "node"
3131
self.shared_id = self.protocol_value["sharedId"]
3232

33-
def to_classic_protocol_value(self) -> Dict:
33+
def to_classic_protocol_value(self) -> Dict[str, Any]:
3434
return {WebElement.identifier: self.shared_id}
3535

3636

@@ -43,7 +43,7 @@ def __init__(self, protocol_value: Dict[str, Any]):
4343
self.browsing_context = self.protocol_value["value"]["context"]
4444

4545

46-
def bidi_deserialize(bidi_value: Union[str, int, Dict]):
46+
def bidi_deserialize(bidi_value: Union[str, int, Dict[str, Any]]) -> Any:
4747
"""
4848
Deserialize the BiDi primitive values, lists and objects to the Python value, keeping non-common data types
4949
in BiDi format.
@@ -82,15 +82,15 @@ def bidi_deserialize(bidi_value: Union[str, int, Dict]):
8282
return int(bidi_value["value"])
8383
# script.RemoteValue https://w3c.github.io/webdriver-bidi/#type-script-RemoteValue
8484
if bidi_value["type"] == "array":
85-
result = []
85+
list_result = []
8686
for item in bidi_value["value"]:
87-
result.append(bidi_deserialize(item))
88-
return result
87+
list_result.append(bidi_deserialize(item))
88+
return list_result
8989
if bidi_value["type"] == "object":
90-
result = {}
90+
dict_result = {}
9191
for item in bidi_value["value"]:
92-
result[bidi_deserialize(item[0])] = bidi_deserialize(item[1])
93-
return result
92+
dict_result[bidi_deserialize(item[0])] = bidi_deserialize(item[1])
93+
return dict_result
9494
if bidi_value["type"] == "node":
9595
return BidiNode(bidi_value)
9696
if bidi_value["type"] == "window":

tools/wptrunner/wptrunner/executors/asyncactions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from typing import List, Optional, TypedDict, Union
1+
# mypy: allow-untyped-defs
2+
3+
4+
from typing import Any, List, Mapping, Optional, TypedDict, Union
25
from webdriver.bidi.protocol import BidiWindow
36

47

0 commit comments

Comments
 (0)