Skip to content

Commit

Permalink
Drop dependency on jaraco.context
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Jul 22, 2024
1 parent 69d65f3 commit a0ea72a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions jaraco/text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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).
Expand All @@ -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):
Expand Down
1 change: 1 addition & 0 deletions newsfragments/xxxx.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop dependency on ``jaraco.context`` -- by :user:`Avasam`
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ classifiers = [
requires-python = ">=3.8"
dependencies = [
"jaraco.functools",
"jaraco.context >= 4.1",
'importlib_resources; python_version < "3.9"',
"autocommand",
"inflect",
Expand Down

0 comments on commit a0ea72a

Please sign in to comment.