Skip to content

Commit

Permalink
Merge pull request #41 from mdsol/feature/replace-cchardet
Browse files Browse the repository at this point in the history
Replace `cchardet` with `charset-normalizer`
  • Loading branch information
ejinotti-mdsol authored Apr 18, 2023
2 parents 0eb9e4d + 693c53a commit d11f814
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
matrix:
os: [Ubuntu, macOS, Windows]
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
include:
- os: Ubuntu
image: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions mauth_client/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import base64
import cchardet
import charset_normalizer
from hashlib import sha512


Expand All @@ -25,10 +25,10 @@ def base64_encode(signature):

def decode(byte_string: bytes) -> str:
"""
Attempt to decode a byte string with utf and fallback to cchardet.
Attempt to decode a byte string with utf and fallback to charset_normalizer.
"""
try:
return byte_string.decode("utf-8")
except UnicodeDecodeError:
encoding = cchardet.detect(byte_string)["encoding"]
encoding = charset_normalizer.detect(byte_string)["encoding"]
return byte_string.decode(encoding)
61 changes: 11 additions & 50 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Software Development :: Libraries :: Python Modules",
]
Expand All @@ -28,7 +29,7 @@ cachetools = "^5.3"
rsa = "^4.0"
importlib-metadata = {version = ">=3.6", python = "<3.8"}
asgiref = "^3.5.2"
cchardet = "^2.1.7"
charset-normalizer = "^3.1.0"

[tool.poetry.dev-dependencies]
boto3 = "^1.24"
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = clean, flake8-py3, py37, py38, py39, py310, stats
envlist = clean, flake8-py3, py37, py38, py39, py310, py311, stats
skipsdist = True

[testenv]
Expand Down

0 comments on commit d11f814

Please sign in to comment.