Remove _TranslationProxy methods that duplicate UserString

The warning in the comment:

> replace function from UserString; it instantiates a self.__class__ for
> the encoding result

Doesn't apply to these methods as they return non text types. Mostly
bool. By removing these methods, there is less to maintain, annotate,
etc.
This commit is contained in:
Jon Dufresne 2018-12-09 11:47:06 -08:00
parent b13a6ff3e6
commit d41b14f20e

View File

@ -74,27 +74,10 @@ class _TranslationProxy(UserString):
else:
return self.data.encode()
def __contains__(self, key):
# type: (Any) -> bool
return key in self.data
def __bool__(self):
# type: () -> bool
return bool(self.data)
__nonzero__ = __bool__ # for python2 compatibility
def __dir__(self):
# type: () -> List[str]
return dir(text_type)
def __iter__(self):
# type: () -> Iterator
return iter(self.data)
def __len__(self):
# type: () -> int
return len(self.data)
def __str__(self):
# type: () -> str
return str(self.data)
@ -127,26 +110,6 @@ class _TranslationProxy(UserString):
# type: (Any) -> unicode
return other * self.data
def __lt__(self, other):
# type: (unicode) -> bool
return self.data < other
def __le__(self, other):
# type: (unicode) -> bool
return self.data <= other
def __eq__(self, other):
# type: (Any) -> bool
return self.data == other
def __gt__(self, other):
# type: (unicode) -> bool
return self.data > other
def __ge__(self, other):
# type: (unicode) -> bool
return self.data >= other
def __getattr__(self, name):
# type: (unicode) -> Any
if name == '__members__':
@ -161,10 +124,6 @@ class _TranslationProxy(UserString):
# type: (Tuple[Callable, Tuple[unicode]]) -> None
self._func, self._args = tup
def __getitem__(self, key): # type: ignore
# type: (Any) -> unicode
return self.data[key]
def __copy__(self):
# type: () -> _TranslationProxy
return self