Skip to content

Commit 8e0cfee

Browse files
fix: narrow Python support and remove Mistral extra (#183)
* fix: narrow supported python versions * fix: remove unavailable mistral extra * fix: exclude crashing mypy release The highest-resolution CI lint jobs selected mypy 2.1.0 and failed during the pre-commit mypy hook with an internal error, even though nearby chunks reported "Success: no issues found". Exclude that specific mypy release so highest-resolution jobs resolve to a non-crashing version while preserving future mypy updates. * fix: run mypy pre-commit as one check The CI lint failure was not limited to one mypy release: highest-resolution jobs crashed with mypy 2.1.0 and then 2.0.0, and local pre-commit also reproduced an internal error with mypy 1.20.1. In each failure, pre-commit had split the hook into several 4-file mypy invocations.\n\nRun mypy once over src and tests, and disable filename passing for the hook. This matches the direct project-level mypy invocation, which passes across the tested mypy versions, and avoids chunked partial graph analysis/cache/report interactions. * fix: address Mistral OCR review comments Keep the mistral-ocr extra as an empty compatibility placeholder so existing raglite[mistral-ocr] install commands keep resolving without pulling the quarantined mistralai package through --all-extras. Also clarify lazy-import errors so users know an incompatible installed mistralai version may need upgrading, not just installation.
1 parent 3b3db9e commit 8e0cfee

4 files changed

Lines changed: 11 additions & 16 deletions

File tree

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ repos:
6868
types_or: [python, pyi]
6969
- id: mypy
7070
name: mypy
71-
entry: mypy
71+
entry: mypy src tests
7272
language: system
73+
pass_filenames: false
7374
types: [python]

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ To add support for filetypes other than PDF, use the `pandoc` extra:
7070
pip install raglite[pandoc]
7171
```
7272

73-
To add support for high-quality document processing with [Mistral OCR](https://docs.mistral.ai/capabilities/document/), use the `mistral-ocr` extra:
73+
To add support for high-quality document processing with [Mistral OCR](https://docs.mistral.ai/capabilities/document/), install `mistralai`:
7474

7575
```sh
76-
pip install raglite[mistral-ocr]
76+
pip install mistralai
7777
```
7878

7979
To add support for evaluation, use the `ragas` extra:
@@ -160,7 +160,7 @@ my_config = RAGLiteConfig(
160160
> ✍️ To insert documents other than PDF, install the `pandoc` extra with `pip install raglite[pandoc]`.
161161
162162
> [!TIP]
163-
> 🔎 For higher-quality document processing with automatic image descriptions, install the `mistral-ocr` extra with `pip install raglite[mistral-ocr]` and configure it as follows:
163+
> 🔎 For higher-quality document processing with automatic image descriptions, install `mistralai` and configure it as follows:
164164
> ```python
165165
> from raglite import RAGLiteConfig, MistralOCRConfig
166166
>
@@ -490,7 +490,7 @@ The following development environments are supported:
490490
491491
- This project follows the [Conventional Commits](https://www.conventionalcommits.org/) standard to automate [Semantic Versioning](https://semver.org/) and [Keep A Changelog](https://keepachangelog.com/) with [Commitizen](https://github.com/commitizen-tools/commitizen).
492492
- Run `poe` from within the development environment to print a list of [Poe the Poet](https://github.com/nat-n/poethepoet) tasks available to run on this project.
493-
- Run `uv add {package}` from within the development environment to install a run time dependency and add it to `pyproject.toml` and `uv.lock`. Add `--dev` to install a development dependency.
493+
- Run `uv add {package}` from within the development environment to install a run time dependency and add it to `pyproject.toml`. Add `--dev` to install a development dependency.
494494
- Run `uv sync --upgrade` from within the development environment to upgrade all dependencies to the latest versions allowed by `pyproject.toml`. Add `--only-dev` to upgrade the development dependencies only.
495495
- Run `cz bump` to bump the package's version, update the `CHANGELOG.md`, and create a git tag. Then push the changes and the git tag with `git push origin main --tags`.
496496

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ readme = "README.md"
1010
authors = [
1111
{ name = "Laurent Sorber", email = "laurent@superlinear.eu" },
1212
]
13-
requires-python = ">=3.10,<4.0"
13+
requires-python = ">=3.10,<3.14"
1414
dependencies = [
1515
# Configuration:
1616
"platformdirs (>=4.0.0)",
@@ -81,8 +81,8 @@ chainlit = ["chainlit (>=2.0.0)"]
8181
# Large Language Models:
8282
llama-cpp-python = ["llama-cpp-python (>=0.3.9)"]
8383
# Markdown conversion:
84-
mistral-ocr = ["mistralai (>=1.10.1)"]
8584
pandoc = ["pypandoc-binary (>=1.13)"]
85+
mistral-ocr = []
8686
# Evaluation:
8787
ragas = ["pandas (>=2.1.1)", "ragas (>=0.3.3)"]
8888
# Benchmarking:

src/raglite/_mistral_ocr.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,7 @@ def _get_mistral_client(processor_config: MistralOCRConfig) -> Any:
7373
try:
7474
from mistralai import Mistral
7575
except ImportError as e:
76-
error_msg = (
77-
"To use MistralOCR, please install the `mistral-ocr` extra: "
78-
"`pip install raglite[mistral-ocr]` or `uv add raglite[mistral-ocr]`."
79-
)
76+
error_msg = "To use MistralOCR, please install or upgrade `mistralai`."
8077
raise ImportError(error_msg) from e
8178

8279
api_key = _get_api_key(processor_config)
@@ -88,10 +85,7 @@ def _get_response_format_converter() -> Any:
8885
try:
8986
from mistralai.extra import response_format_from_pydantic_model
9087
except ImportError as e:
91-
error_msg = (
92-
"To use MistralOCR, please install the `mistral-ocr` extra: "
93-
"`uv add raglite[mistral-ocr]` or `pip install raglite[mistral-ocr]`."
94-
)
88+
error_msg = "To use MistralOCR, please install or upgrade `mistralai`."
9589
raise ImportError(error_msg) from e
9690
return response_format_from_pydantic_model
9791

@@ -183,7 +177,7 @@ def mistral_ocr_to_markdown(doc_path: Path, *, processor_config: MistralOCRConfi
183177
Raises
184178
------
185179
ImportError
186-
If the mistralai package is not installed.
180+
If the mistralai package is not installed or is incompatible.
187181
ValueError
188182
If MISTRAL_API_KEY is not set and MistralOCRConfig.api_key is None.
189183
MistralOCRError

0 commit comments

Comments
 (0)