import time

import redis


def connect_to_redis(*args, **kwargs):
    client = redis.Redis(*args, unix_socket_path='redis/redis.sock', **kwargs)

    while True:
        try:
            assert client.ping()
        except (redis.exceptions.ConnectionError, AssertionError):
            time.sleep(0.5)
        else:
            return client

import time

import redis


def connect_to_redis(*args, **kwargs):
    client = redis.Redis(
        *args,
        unix_socket_path='redis/redis.sock',
        decode_responses=True,
        **kwargs
    )

    while True:
        try:
            assert client.ping()
        except (redis.exceptions.ConnectionError, AssertionError):
            time.sleep(0.5)
        else:
            return client

Convert Redis keys and values to str
Convert Redis keys and values to str

  import time
  
  import redis
  
  
  def connect_to_redis(*args, **kwargs):
-     client = redis.Redis(*args, unix_socket_path='redis/redis.sock', **kwargs)
+     client = redis.Redis(
+         *args,
+         unix_socket_path='redis/redis.sock',
+         decode_responses=True,
+         **kwargs
+     )
  
      while True:
          try:
              assert client.ping()
          except (redis.exceptions.ConnectionError, AssertionError):
              time.sleep(0.5)
          else:
              return client
  
Convert Redis keys and values to str
## Code Before:
import time

import redis


def connect_to_redis(*args, **kwargs):
    client = redis.Redis(*args, unix_socket_path='redis/redis.sock', **kwargs)

    while True:
        try:
            assert client.ping()
        except (redis.exceptions.ConnectionError, AssertionError):
            time.sleep(0.5)
        else:
            return client

## Instruction:
Convert Redis keys and values to str
## Code After:
import time

import redis


def connect_to_redis(*args, **kwargs):
    client = redis.Redis(
        *args,
        unix_socket_path='redis/redis.sock',
        decode_responses=True,
        **kwargs
    )

    while True:
        try:
            assert client.ping()
        except (redis.exceptions.ConnectionError, AssertionError):
            time.sleep(0.5)
        else:
            return client
