Skip to content

Commit

Permalink
removed python3.7 stdlib compats
Browse files Browse the repository at this point in the history
  • Loading branch information
mjurbanski-reef committed Aug 9, 2024
1 parent b5ab70a commit 9a64d85
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions b2/_internal/_utils/python_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
"""
Utilities for compatibility with older Python versions.
"""
import functools
import shlex
import sys

if sys.version_info < (3, 9):
Expand All @@ -21,34 +19,3 @@ def removeprefix(s: str, prefix: str) -> str:

else:
removeprefix = str.removeprefix

if sys.version_info < (3, 8):

class singledispatchmethod:
"""
singledispatchmethod backport for Python 3.7.
There are no guarantees for its completeness.
"""

def __init__(self, method):
self.dispatcher = functools.singledispatch(method)
self.method = method

def register(self, cls, method=None):
return self.dispatcher.register(cls, func=method)

def __get__(self, obj, cls):
@functools.wraps(self.method)
def method_wrapper(arg, *args, **kwargs):
method_desc = self.dispatcher.dispatch(arg.__class__)
return method_desc.__get__(obj, cls)(arg, *args, **kwargs)

method_wrapper.register = self.register
return method_wrapper

def shlex_join(split_command):
return ' '.join(shlex.quote(arg) for arg in split_command)
else:
singledispatchmethod = functools.singledispatchmethod
shlex_join = shlex.join

0 comments on commit 9a64d85

Please sign in to comment.