Rename OCROptions to OcrOptions for consistency

Technically OCROptions is more Pythonic but we have several pre-existing classes named OcrWhatever. Go with the local flow.
This commit is contained in:
James R. Barlow
2026-01-12 23:37:54 -08:00
parent 36dea181e6
commit 740f67091c
26 changed files with 197 additions and 190 deletions
+4 -4
View File
@@ -122,10 +122,10 @@ When OCRmyPDF succeeds conditionally, it returns an integer exit code.
Starting in OCRmyPDF v16.13.0, the plugin interface has been updated:
- Plugin hooks now receive `OCROptions` objects instead of `argparse.Namespace`
- `OCROptions` provides the same attribute access as `Namespace` (duck-typing compatible)
- Plugin developers should update type hints: `from ocrmypdf._options import OCROptions`
- Plugin hooks now receive `OcrOptions` objects instead of `argparse.Namespace`
- `OcrOptions` provides the same attribute access as `Namespace` (duck-typing compatible)
- Plugin developers should update type hints: `from ocrmypdf._options import OcrOptions`
- Built-in plugins no longer modify options in-place for better immutability
Most existing plugins will continue working without modification due to the
duck-typing compatibility between `OCROptions` and `Namespace`.
duck-typing compatibility between `OcrOptions` and `Namespace`.
+1 -1
View File
@@ -17,7 +17,7 @@ should be mainly of interest to plugin developers.
```{eval-rst}
.. automodule:: ocrmypdf._options
:members: OCROptions
:members: OcrOptions
```
## ocrmypdf.exceptions
+1 -1
View File
@@ -185,7 +185,7 @@ Both access patterns are equivalent and return the same values.
:::{note}
**Plugin Interface Change**: Starting in OCRmyPDF v16.13.0, plugin hooks receive
`OCROptions` objects instead of `argparse.Namespace` objects. Most plugins will
`OcrOptions` objects instead of `argparse.Namespace` objects. Most plugins will
continue working due to duck-typing compatibility, but plugin developers should
update their type hints accordingly.
:::
+5 -5
View File
@@ -29,24 +29,24 @@ official when it's tagged and posted to PyPI.
**Breaking changes**
- **Plugin interface migration**: Plugin hooks now receive `OCROptions` objects instead of
- **Plugin interface migration**: Plugin hooks now receive `OcrOptions` objects instead of
`argparse.Namespace` objects. Most plugins will continue working due to duck-typing
compatibility, but plugin developers should update their type hints from `Namespace`
to `OCROptions`.
to `OcrOptions`.
- Built-in plugins no longer modify options in-place, improving immutability and
code clarity.
**API improvements**
- Centralized validation logic in the `OCROptions` Pydantic model
- Centralized validation logic in the `OcrOptions` Pydantic model
- Removed scattered option mutation throughout the codebase
- Better type safety for plugin development
- Simplified plugin option handling
**Migration guide for plugin developers**
- Update imports: `from ocrmypdf._options import OCROptions`
- Update type hints: `def check_options(options: OCROptions)` instead of `options: Namespace`
- Update imports: `from ocrmypdf._options import OcrOptions`
- Update type hints: `def check_options(options: OcrOptions)` instead of `options: Namespace`
- Attribute access remains unchanged: `options.languages`, `options.output_type`, etc.
- Remove any in-place option modifications - compute values at point of use instead
- Most existing plugins will continue working without changes due to duck-typing