Skip to content

Commit 8ecd961

Browse files
authored
chore: don't use a function call in default initializer (#1606)
1 parent 9fc1777 commit 8ecd961

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

playwright/_impl/_impl_to_api_mapping.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ def from_impl_list(self, items: List[Any]) -> List[Any]:
8787
def from_impl_dict(self, map: Dict[str, Any]) -> Dict[str, Any]:
8888
return {name: self.from_impl(value) for name, value in map.items()}
8989

90-
def to_impl(self, obj: Any, visited: Map[Any, Union[List, Dict]] = Map()) -> Any:
90+
def to_impl(
91+
self, obj: Any, visited: Optional[Map[Any, Union[List, Dict]]] = None
92+
) -> Any:
93+
if visited is None:
94+
visited = Map()
9195
try:
9296
if not obj:
9397
return obj

playwright/_impl/_js_handle.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ async def json_value(self) -> Any:
105105

106106

107107
def serialize_value(
108-
value: Any, handles: List[JSHandle], visitor_info: VisitorInfo = VisitorInfo()
108+
value: Any, handles: List[JSHandle], visitor_info: Optional[VisitorInfo] = None
109109
) -> Any:
110+
if visitor_info is None:
111+
visitor_info = VisitorInfo()
110112
if isinstance(value, JSHandle):
111113
h = len(handles)
112114
handles.append(value._channel)
@@ -160,7 +162,9 @@ def serialize_argument(arg: Serializable = None) -> Any:
160162
return dict(value=value, handles=handles)
161163

162164

163-
def parse_value(value: Any, refs: Dict[int, Any] = {}) -> Any:
165+
def parse_value(value: Any, refs: Optional[Dict[int, Any]] = None) -> Any:
166+
if refs is None:
167+
refs = {}
164168
if value is None:
165169
return None
166170
if isinstance(value, dict):

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ ignore = ["tests/async/", "scripts/", "examples/"]
3636
pythonVersion = "3.7"
3737
reportMissingImports = false
3838
reportTypedDictNotRequiredAccess = false
39+
reportCallInDefaultInitializer = true

0 commit comments

Comments
 (0)