conf.py
def update_from_env(settings_class, *, prefix):
    """Update a global settings class with environment variables.

    This function pulls environment variables starting with ``prefix``, removes
    ``prefix``, lower cases the remaining suffix and sets the value on the
    class attribute.

    .. note::

       This function is thread-safe.

    Args:
        settings_class: The global settings class to update
        prefix: The prefix of the environment variables to consider.
    """
    type_hints = get_type_hints(settings_class)
    with threading.Lock():
        for k in os.environ:
            if not k.startswith(prefix):
                continue

            attr = k.replace(prefix, "").lower()

            if attr in getattr(settings_class, "_no_environ_set", ()):
                logger.debug(f"Skipping {k}. Disallowed set from environ.")
                continue

            v = os.getenv(k)
            try:
                # Attempt to typecast based on the hint.
                v = type_hints.get(attr)(v)
            except (AttributeError, KeyError, TypeError):
                pass


            logger.debug(
                "Found environment variable: {}. ({}={})".format(
                    k,
                    attr,
                    "****{}".format(v[:4]) if "password" in attr else v))
            setattr(settings_class, attr, v)
Update a global settings class with environment variables.

    This function pulls environment variables starting with ``prefix``, removes
    ``prefix``, lower cases the remaining suffix and sets the value on the
    class attribute.

    .. note::

       This function is thread-safe.

    Args:
        settings_class: The global settings class to update
        prefix: The prefix of the environment variables to consider.
    
Update a global settings class with environment variables.



This function is thread-safe.
Update a global settings class with environment variables . This function is thread - safe .
def update_from_env(settings_class, *, prefix):
    type_hints = get_type_hints(settings_class)
    with threading.Lock():
        for k in os.environ:
            if not k.startswith(prefix):
                continue
            attr = k.replace(prefix, "").lower()
            if attr in getattr(settings_class, "_no_environ_set", ()):
                logger.debug(f"Skipping {k}. Disallowed set from environ.")
                continue
            v = os.getenv(k)
            try:
                v = type_hints.get(attr)(v)
            except (AttributeError, KeyError, TypeError):
                pass
            logger.debug(
                "Found environment variable: {}. ({}={})".format(
                    k,
                    attr,
                    "****{}".format(v[:4]) if "password" in attr else v))
            setattr(settings_class, attr, v)
def update_from_env ( settings_class , * , prefix ) : type_hints = get_type_hints ( settings_class ) with threading . Lock ( ) : for k in os . environ : if not k . startswith ( prefix ) : continue attr = k . replace ( prefix , "" ) . lower ( ) if attr in getattr ( settings_class , "_no_environ_set" , ( ) ) : logger . debug ( f"Skipping {k}. Disallowed set from environ." ) continue v = os . getenv ( k ) try : v = type_hints . get ( attr ) ( v ) except ( AttributeError , KeyError , TypeError ) : pass logger . debug ( "Found environment variable: {}. ({}={})" . format ( k , attr , "****{}" . format ( v [ : 4 ] ) if "password" in attr else v ) ) setattr ( settings_class , attr , v )
Update a global settings class with environment variables.
Update a global settings class with environment variables .
"""Update a global settings class with environment variables.

    This function pulls environment variables starting with ``prefix``, removes
    ``prefix``, lower cases the remaining suffix and sets the value on the
    class attribute.

    .. note::

       This function is thread-safe.

    Args:
        settings_class: The global settings class to update
        prefix: The prefix of the environment variables to consider.
    """ # Attempt to typecast based on the hint.
settings_class
The global settings class to update
The global settings class to update
prefix
The prefix of the environment variables to consider.
The prefix of the environment variables to consider .