Skip to content

refactor: import UniversalDetector from chardet top-level - #1215

Open
jellyfishing2346 wants to merge 1 commit into
capitalone:mainfrom
jellyfishing2346:fix/issue-1204
Open

jellyfishing2346 wants to merge 1 commit into
capitalone:mainfrom
jellyfishing2346:fix/issue-1204

Conversation

@jellyfishing2346

Copy link
Copy Markdown

Changed from 'from chardet.universaldetector import UniversalDetector' to 'from chardet import UniversalDetector' to support chardet 0.7.0+ which changed their import structure.

Fixes #1204

@jellyfishing2346
jellyfishing2346 requested a review from a team as a code owner July 31, 2026 03:29
@CLAassistant

CLAassistant commented Jul 31, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@jellyfishing2346

Copy link
Copy Markdown
Author

Hi @leos, I was wondering if you happen to have any feedback on this PR.

@JGSweets

JGSweets commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

@jellyfishing2346 does this still support backwards compatibility?

If reqs don't require the new version then this could break older versions.

@jellyfishing2346

Copy link
Copy Markdown
Author

@JGSweets it doesn’t.

@JGSweets

JGSweets commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

@jellyfishing2346 do you know if they ever resolved this issue of changing the default likelihood:
#1205 (comment)

Also, unsure if they resolved their license issue for 7.0.0+

@jellyfishing2346

Copy link
Copy Markdown
Author

@JGSweets I don't believe I know if they did.

@jellyfishing2346 jellyfishing2346 changed the title Fix chardet import for compatibility with chardet >= 0.7.0 refactor: import UniversalDetector from chardet top-level Sep 27, 2026
Avoids the deprecated chardet.universaldetector path in chardet 7.x. The top-level import works on older versions too.

Refs capitalone#1204
@jellyfishing2346

Copy link
Copy Markdown
Author

@JGSweets Correction to my earlier answer: this change is backwards compatible. I tested from chardet import UniversalDetector against the full range allowed in requirements.txt (>=3.0.4,<7.0.0): 3.0.4, 4.0.0, 5.2.0 and 6.0.0. It works on all of them, and on 7.6.0 as well.

On your other questions: I haven't seen the utf-8 → windows-1252 detection change or the 7.x licensing dispute (chardet/chardet#327) resolved, so I don't think this PR should lift the <7.0.0 pin. I've rescoped it as a small forward-compat cleanup instead: the old chardet.universaldetector path is deprecated in 7.x, so this avoids a future break if the pin is ever relaxed. I've rebased on the latest main and updated the title. If you'd rather not take it given the pin, I'm happy to close it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] chardet newest version breaking change

3 participants