Upgrade chardet from 5.2.0 to 7.x

Aperta
#899 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend, testing

Direzione di ricerca

Start with ricecooker/utils/encodings.py at decode_text and inspect the listed failures in tests/pipeline/test_convert.py, tests/test_files.py, and tests/utils/test_remote_cli.py. Check the chardet.detect() call in ricecooker/utils/html.py as well. Update the dependency pins and compatibility behavior, then verify the four listed tests pass and add coverage for cp1252 HTML served without a charset.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

dependencies python TAG: tech update / debt

Overview

Dependabot PR #896 bumped chardet from 5.2.0 to 7.7.0 and failed CI on all 15 jobs, so it was closed. chardet 7 detects short cp1252 text as other encodings and no longer fails on undecodable input. The pinned requests 2.32.5 also rejects it. Land the bump and the code changes it needs in one PR.

Complexity: Medium
Target branch: main

Context
  • decode_text (ricecooker/utils/encodings.py:163) passes chardet.detect() up to 4 KiB of bytes after the first invalid UTF-8 byte. Under 7.7.0, Café in cp1252 decodes as Thai Caf้ and Maria’s as Maria\x92s. Subtitles and IMSCP titles upload as mojibake with no error.
  • Since 7.6.0, detect() returns only encodings that decode the whole input, so an undecodable subtitle now converts instead of failing.
  • ricecooker/utils/html.py:185 also calls chardet.detect(), on HTTP text bodies served without a charset.
  • requests 2.32.5 checks for chardet <6 on import and prints a RequestsDependencyWarning to stderr otherwise. That stderr output breaks test_chef_script_outside_cwd_is_refused.
  • Tests that fail on #896:
    • tests/pipeline/test_convert.py::TestIMSCPDecomposition::test_manifest_misdeclared_as_utf8_keeps_titles[late-cp1252-only-byte]
    • tests/test_files.py::test_non_utf8_subtitle_converts_in_its_encoding
    • tests/test_files.py::test_undecodable_subtitle_fails_only_that_file
    • tests/utils/test_remote_cli.py::test_chef_script_outside_cwd_is_refused
The Change
  • Bump chardet to 7.7.0 or later 7.x.
  • Bump requests to ≥2.33.0 in the same PR (open as #897, to 2.34.2). 2.33.0 is the first release that accepts chardet <8.
  • decode_text should keep returning the 5.2.0 results for cp1252 text and keep failing on undecodable subtitles. chardet 7's prefer_superset=True (the 8.0 default) and include_encodings are available.
  • Keep the html.py charset guess working under chardet 7.
Acceptance Criteria
  • uv.lock pins chardet 7.x and requests ≥2.33.0.
  • The four tests listed in Context pass, unchanged, on Python 3.10–3.14 on Linux, macOS and Windows.
  • Importing ricecooker prints no RequestsDependencyWarning.
  • A test covers html.py's charset guess for a cp1252 text/html response sent without a charset.
References

AI usage

rtibblesbot (Claude Code) reviewed #896, read the failing CI logs and the chardet and requests sources, and drafted this issue.

Filed from #896's review.

Lingua principale
Python
Stelle
33
Fork
83
Merge medio
5g 16h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di learningequality/ricecooker

Tutte le issue di learningequality/ricecooker

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.