From 21d69ffe873d685b7e2aea876261d0d9f37b84b7 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Tue, 9 Dec 2025 23:52:37 -0800 Subject: [PATCH] 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) --- src/ocrmypdf/_options.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ocrmypdf/_options.py b/src/ocrmypdf/_options.py index 1c426712..8f3e020b 100644 --- a/src/ocrmypdf/_options.py +++ b/src/ocrmypdf/_options.py @@ -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')