fix: set default value for fast_web_view to prevent NoneType errors

This change ensures that `fast_web_view` always has a default value of 1.0, preventing the TypeError that was occurring in multiple test cases when trying to multiply `None` with an integer.

The modifications include:
1. Changing the type hint for `fast_web_view` from `float | None` to `float`
2. Setting a default value of 1.0
3. Adding a validation step in the `model_validator` to set the default value if not provided

Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
James R. Barlow
2025-12-21 12:21:47 -08:00
co-authored by aider
parent 3baeb83533
commit 21d69ffe87
+3 -1
View File
@@ -153,7 +153,7 @@ class OCROptions(BaseModel):
color_conversion_strategy: str = 'RGB'
user_words: os.PathLike | None = None
user_patterns: os.PathLike | None = None
fast_web_view: float | None = None
fast_web_view: float = 1.0
continue_on_soft_render_error: bool | None = None
# Plugin system
@@ -382,6 +382,8 @@ class OCROptions(BaseModel):
data['color_conversion_strategy'] = 'RGB'
if data.get('pdfa_image_compression') is None:
data['pdfa_image_compression'] = 'auto'
if data.get('fast_web_view') is None:
data['fast_web_view'] = 1.0
return data
@model_validator(mode='after')