fix: add lossless_reconstruction attribute to OCROptions for compatibility

Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>

fix: resolve recursion error in lossless_reconstruction option

Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>

fix: ensure lossless_reconstruction attribute is added to Namespace

Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>

fix: ensure lossless_reconstruction attribute is correctly propagated to PageContext

Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
James R. Barlow
2025-12-13 11:42:49 -08:00
co-authored by aider
parent 66a3e8508e
commit 7575dddefc
2 changed files with 2 additions and 4 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ class PdfContext:
# Accept both types during transition
if isinstance(options, Namespace):
self.options = OCROptions.from_namespace(options)
self._namespace_options = options # Keep original for PageContext
self._namespace_options = self.options.to_namespace() # Use converted namespace with computed attributes
elif isinstance(options, OCROptions):
self.options = options
self._namespace_options = options.to_namespace() # Convert immediately for PageContext
+1 -3
View File
@@ -147,8 +147,6 @@ class OCROptions(BaseModel):
# Plugin system
plugins: Sequence[Path | str] | None = None
# Computed/derived options (set during validation)
lossless_reconstruction: bool = False
# Store any extra attributes (for plugins and dynamic options)
extra_attrs: dict[str, Any] = Field(
@@ -217,7 +215,7 @@ class OCROptions(BaseModel):
field_value = getattr(self, field_name)
setattr(ns, field_name, field_value)
# Add extra attributes
# Add extra attributes (including computed ones like lossless_reconstruction)
for key, value in self.extra_attrs.items():
setattr(ns, key, value)