Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/requests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@
except ImportError:
charset_normalizer_version = None

try:
from chardet import __version__ as chardet_version # type: ignore[import-not-found]
except ImportError:
chardet_version = None
# chardet is an optional dependency that should only be used if the
# use-chardet-on-py3 extra is installed. We no longer attempt to import it
# opportunistically, to avoid version warnings when chardet is installed
# by other packages without respecting requests' version constraints.
chardet_version = None


def check_compatibility(
Expand Down
8 changes: 4 additions & 4 deletions src/requests/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
except ImportError:
charset_normalizer = None

try:
import chardet # type: ignore[import-not-found]
except ImportError:
chardet = None
# chardet is an optional dependency that should only be used if the
# use-chardet-on-py3 extra is installed. We no longer attempt to import it
# opportunistically.
chardet = None

try:
from urllib3.contrib import pyopenssl
Expand Down