3
3
import json
4
4
import logging
5
5
from datetime import datetime
6
- from typing import Any , Callable , List , Optional , Union , get_args , get_origin
6
+ from typing import Any , Callable , Optional , Union , get_args , get_origin
7
7
8
8
from pydantic import AnyUrl , BaseModel , Field , HttpUrl , create_model
9
9
from pydantic .fields import FieldInfo
@@ -701,7 +701,7 @@ async def draw_observe_overlay(page, elements):
701
701
702
702
Args:
703
703
page: Playwright page object
704
- elements: List of observation results with selectors
704
+ elements: list of observation results with selectors
705
705
"""
706
706
if not elements :
707
707
return
@@ -961,15 +961,15 @@ def transform_type(annotation, path):
961
961
if annotation is None :
962
962
return annotation , []
963
963
964
- # Get the origin type for generic types (List , Optional, etc.)
964
+ # Get the origin type for generic types (list , Optional, etc.)
965
965
origin = get_origin (annotation )
966
966
967
967
# Case 1: It's a URL type (AnyUrl, HttpUrl)
968
968
if is_url_type (annotation ):
969
969
return int , [{"segments" : []}]
970
970
971
- # Case 2: It's a List or other generic container
972
- if origin in (list , List ):
971
+ # Case 2: It's a list or other generic container
972
+ if origin in (list , list ):
973
973
args = get_args (annotation )
974
974
if not args :
975
975
return annotation , []
@@ -980,11 +980,11 @@ def transform_type(annotation, path):
980
980
981
981
if new_elem_type != elem_type :
982
982
# Transform the list type to use the new element type
983
- if len (args ) > 1 : # Handle List with multiple type args
983
+ if len (args ) > 1 : # Handle list with multiple type args
984
984
new_args = (new_elem_type ,) + args [1 :]
985
985
new_type = origin [new_args ]
986
986
else :
987
- new_type = List [new_elem_type ]
987
+ new_type = list [new_elem_type ]
988
988
989
989
# Update paths to include the array wildcard
990
990
url_paths = []
@@ -1059,8 +1059,8 @@ def is_url_type(annotation):
1059
1059
# Check for URL in generic containers
1060
1060
origin = get_origin (annotation )
1061
1061
1062
- # Handle List [URL]
1063
- if origin in (list , List ):
1062
+ # Handle list [URL]
1063
+ if origin in (list , list ):
1064
1064
args = get_args (annotation )
1065
1065
if args :
1066
1066
return is_url_type (args [0 ])
@@ -1079,7 +1079,7 @@ def inject_urls(result, url_paths, id_to_url_mapping):
1079
1079
1080
1080
Args:
1081
1081
result: The result data structure
1082
- url_paths: List of paths to URL fields in the structure
1082
+ url_paths: list of paths to URL fields in the structure
1083
1083
id_to_url_mapping: Dictionary mapping numeric IDs to URLs
1084
1084
1085
1085
Returns:
0 commit comments