Skip to content

Commit

Permalink
Delete the Redis.lolwut() monkey patch (#464)
Browse files Browse the repository at this point in the history
* Delete the Redis.lolwut() monkey patch

I got `Redis.lolwut()` merged upstream!
redis/redis-py#1568

* Bump version number
  • Loading branch information
brainix authored Oct 1, 2021
1 parent 0aa4751 commit 725c8f4
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 36 deletions.
2 changes: 1 addition & 1 deletion pottery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@


__title__ = 'pottery'
__version__ = '1.4.2'
__version__ = '1.4.3'
__description__, __long_description__ = (
s.strip() for s in __doc__.split(sep='\n\n', maxsplit=1)
)
Expand Down
21 changes: 0 additions & 21 deletions pottery/monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,3 @@ def _default(self: Any, obj: Any) -> Union[Dict[str, Any], List[Any], str]:
'instance of any class that defines a .to_dict(), .to_list(), or .to_str() '
'method'
)


# Monkey patch the Redis client to implement the LOLWUT command.
# 1. LOLWUT command: https://redis.io/commands/lolwut
# 2. PR upstream: https://github.com/andymccurdy/redis-py/pull/1448

from redis import Redis # isort: skip

def lolwut(self: Redis, *version_numbers: int) -> bytes:
"Get the Redis version and a piece of generative computer art"
if version_numbers:
return self.execute_command('LOLWUT VERSION', *version_numbers)
else:
return self.execute_command('LOLWUT')

Redis.lolwut = lolwut # type: ignore

_logger.info(
'Monkey patched redis.Redis.lolwut() to get the Redis version and a piece '
'of generative art'
)
14 changes: 0 additions & 14 deletions tests/test_monkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,3 @@ def test_json_encoder(self):
"Object of type 'object' is not JSON serializable", # Python 3.6
'Object of type object is not JSON serializable', # Python 3.7+
}

def test_redis_lolwut(self):
lolwut = self._lolwut()
assert 'Redis ver.' in lolwut

lolwut = self._lolwut(5, 6, 7, 8)
assert 'Redis ver.' in lolwut

def _lolwut(self, *args: int) -> str:
response = self.redis.lolwut(*args)
try:
return response.decode('utf-8')
except AttributeError: # pragma: no cover
return response

0 comments on commit 725c8f4

Please sign in to comment.