Search code examples
pythondebuggingrichsupabase-py

Is this a Python Rich's feature or a bug?


I'm making an app in Python using Supabase and Rich. Everytime I make a request to the Supabase API, Rich will print some kind of log, and I don't know if this is a feature that I can disable or a bug.

enter image description here

I've tried uninstalling Rich and Supabase does not give any output by default.

Also, I've reduced the algorithm to a basic testing file. This is the only thing I do, so it's nothing I could've configured.

from os import environ
from dotenv import load_dotenv
from supabase import Client, create_client

load_dotenv()

URL: str = environ.get('SUPABASE_URL')
KEY: str = environ.get('SUPABASE_KEY')

supa: Client = create_client(URL, KEY)

query = supa.table('watched').select('*').execute()

Solution

Finally I've solved it after trying some methods:

import logging
import sys

supabase_logger = logging.getLogger('supabase')
rich_logger = logging.getLogger('rich')

# Method 1
supabase_logger.propagate = False
rich_logger.propagate = False

# Method 2
supabase_logger.disabled = True
rich_logger.disabled = True

# Method 3 (51 must be any number above 50)
logging.disable(51)

# Method 4 (This is the one that worked for me)
logging.disable(sys.maxsize)

Solution

  • #likely due to the default logging configuration in the Supabase Python library

    import logging
    
    #Disable logging from the Supabase library
    logging.getLogger("supabase").setLevel(logging.WARNING)