From a0ea72aaebf87186f1e0217c346217283266eb1b Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 21 Jul 2024 22:26:31 -0400 Subject: [PATCH] Drop dependency on `jaraco.context` --- jaraco/text/__init__.py | 14 ++++++-------- newsfragments/xxxx.misc.rst | 1 + pyproject.toml | 1 - 3 files changed, 7 insertions(+), 9 deletions(-) create mode 100644 newsfragments/xxxx.misc.rst diff --git a/jaraco/text/__init__.py b/jaraco/text/__init__.py index 8567200..01a1eaf 100644 --- a/jaraco/text/__init__.py +++ b/jaraco/text/__init__.py @@ -10,7 +10,6 @@ except ImportError: # pragma: nocover from importlib_resources import files # type: ignore -from jaraco.context import ExceptionTrap from jaraco.functools import compose, method_cache @@ -134,12 +133,7 @@ def split(self, splitter=' ', maxsplit=0): return pattern.split(self, maxsplit) -# Python 3.8 compatibility -_unicode_trap = ExceptionTrap(UnicodeDecodeError) - - -@_unicode_trap.passes -def is_decodable(value): +def is_decodable(value: bytes) -> bool: r""" Return True if the supplied value is decodable (using the default encoding). @@ -149,7 +143,11 @@ def is_decodable(value): >>> is_decodable(b'\x32') True """ - value.decode() + try: + value.decode() + return True + except UnicodeDecodeError: + return False def is_binary(value): diff --git a/newsfragments/xxxx.misc.rst b/newsfragments/xxxx.misc.rst new file mode 100644 index 0000000..24890de --- /dev/null +++ b/newsfragments/xxxx.misc.rst @@ -0,0 +1 @@ +Drop dependency on ``jaraco.context`` -- by :user:`Avasam` diff --git a/pyproject.toml b/pyproject.toml index e96d197..37ebce8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,6 @@ classifiers = [ requires-python = ">=3.8" dependencies = [ "jaraco.functools", - "jaraco.context >= 4.1", 'importlib_resources; python_version < "3.9"', "autocommand", "inflect",