Skip to content

Commit 91b9855

Browse files
lint
1 parent 65952ce commit 91b9855

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

stagehand/handlers/extract_handler.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
ExtractResult,
1515
)
1616
from stagehand.utils import (
17+
convert_dict_keys_to_snake_case,
1718
inject_urls,
1819
transform_url_strings_to_ids,
19-
convert_dict_keys_to_snake_case,
2020
)
2121

2222
T = TypeVar("T", bound=BaseModel)
@@ -151,7 +151,9 @@ async def extract(
151151

152152
processed_data_payload = raw_data_dict # Default to the raw dictionary
153153

154-
if schema and isinstance(raw_data_dict, dict): # schema is the Pydantic model type
154+
if schema and isinstance(
155+
raw_data_dict, dict
156+
): # schema is the Pydantic model type
155157
# Try direct validation first
156158
try:
157159
validated_model_instance = schema.model_validate(raw_data_dict)

stagehand/page.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,17 @@ async def extract(
416416
except Exception as first_error:
417417
# Fallback: normalize keys to snake_case and try once more
418418
try:
419-
normalized = convert_dict_keys_to_snake_case(processed_data_payload)
419+
normalized = convert_dict_keys_to_snake_case(
420+
processed_data_payload
421+
)
420422
if not options_obj:
421-
validated_model = EmptyExtractSchema.model_validate(normalized)
423+
validated_model = EmptyExtractSchema.model_validate(
424+
normalized
425+
)
422426
else:
423-
validated_model = schema_to_validate_with.model_validate(normalized)
427+
validated_model = schema_to_validate_with.model_validate(
428+
normalized
429+
)
424430
processed_data_payload = validated_model
425431
except Exception as second_error:
426432
self._stagehand.logger.error(

0 commit comments

Comments
 (0)