@@ -211,7 +211,7 @@ def patch_file(file_path: str, patched_tree: ast.AST) -> None:
211211 if isinstance (subnode , ast .Return ) and isinstance (subnode .value , ast .Call ):
212212 if subnode .value .args and isinstance (subnode .value .args [0 ], ast .Await ):
213213 inner_call = subnode .value .args [0 ].value
214- if isinstance (inner_call , ast .Call ) and inner_call .func .attr == "send" :
214+ if isinstance (inner_call , ast .Call ) and isinstance ( inner_call . func , ast . Attribute ) and inner_call .func .attr == "send" :
215215 for i , arg in enumerate (inner_call .args ):
216216 if isinstance (arg , ast .Call ) and arg .func .id == "dict" :
217217 arg .keywords .append (ast .keyword (
@@ -257,7 +257,7 @@ def patch_file(file_path: str, patched_tree: ast.AST) -> None:
257257 if isinstance (subnode , ast .Return ) and isinstance (subnode .value , ast .Call ):
258258 if subnode .value .args and isinstance (subnode .value .args [0 ], ast .Await ):
259259 inner_call = subnode .value .args [0 ].value
260- if isinstance (inner_call , ast .Call ) and inner_call .func .attr == "send" :
260+ if isinstance (inner_call , ast .Call ) and isinstance ( inner_call . func , ast . Attribute ) and inner_call .func .attr == "send" :
261261 for i , arg in enumerate (inner_call .args ):
262262 if isinstance (arg , ast .Call ) and arg .func .id == "dict" :
263263 arg .keywords .append (ast .keyword (
@@ -559,7 +559,7 @@ async def route_handler(route: Route) -> None:
559559 if isinstance (subnode , ast .Return ) and isinstance (subnode .value , ast .Call ):
560560 if subnode .value .args and isinstance (subnode .value .args [0 ], ast .Await ):
561561 inner_call = subnode .value .args [0 ].value
562- if isinstance (inner_call , ast .Call ) and inner_call .func .attr == "send" :
562+ if isinstance (inner_call , ast .Call ) and isinstance ( inner_call . func , ast . Attribute ) and inner_call .func .attr == "send" :
563563 for i , arg in enumerate (inner_call .args ):
564564 if isinstance (arg , ast .Call ) and arg .func .id == "dict" :
565565 arg .keywords .append (ast .keyword (
@@ -621,7 +621,7 @@ async def route_handler(route: Route) -> None:
621621
622622 # Modify the inner function call inside return statement
623623 for subnode in ast .walk (node ):
624- if isinstance (subnode , ast .Call ) and subnode .func .attr == node .name :
624+ if isinstance (subnode , ast .Call ) and isinstance ( subnode . func , ast . Attribute ) and subnode .func .attr == node .name :
625625 subnode .keywords .append (
626626 ast .keyword (arg = "isolatedContext" ,
627627 value = ast .Name (id = "isolated_context" ,
@@ -641,7 +641,7 @@ async def route_handler(route: Route) -> None:
641641 node .args .kw_defaults .append (ast .Constant (value = None ))
642642
643643 for subnode in ast .walk (node ):
644- if isinstance (subnode , ast .Call ) and subnode .func .attr == node .name :
644+ if isinstance (subnode , ast .Call ) and isinstance ( subnode . func , ast . Attribute ) and subnode .func .attr == node .name :
645645 subnode .keywords .append (
646646 ast .keyword (arg = "focusControl" , value = ast .Name (id = "focus_control" , ctx = ast .Load ()))
647647 )
@@ -692,7 +692,7 @@ async def route_handler(route: Route) -> None:
692692
693693 # Modify the inner function call inside return statement
694694 for subnode in ast .walk (node ):
695- if isinstance (subnode , ast .Call ) and subnode .func .attr == node .name :
695+ if isinstance (subnode , ast .Call ) and isinstance ( subnode . func , ast . Attribute ) and subnode .func .attr == node .name :
696696 subnode .keywords .append (
697697 ast .keyword (arg = "isolatedContext" ,
698698 value = ast .Name (id = "isolated_context" ,
@@ -715,7 +715,7 @@ async def route_handler(route: Route) -> None:
715715
716716 if class_node .name != "BrowserContext" and node .name != "new_page" :
717717 for subnode in ast .walk (node ):
718- if isinstance (subnode , ast .Call ) and subnode .func .attr == node .name :
718+ if isinstance (subnode , ast .Call ) and isinstance ( subnode . func , ast . Attribute ) and subnode .func .attr == node .name :
719719 subnode .keywords .append (
720720 ast .keyword (arg = "focusControl" , value = ast .Name (id = "focus_control" , ctx = ast .Load ()))
721721 )
0 commit comments