pypa/pipfile

AttributeError while using inject_environment_variables function

djsam113 opened this issue · 0 comments

When I parsed the Pipfile given in the example section, an attribute error came up because the line

requests = { extras = ['socks'] },

coz there is a list but it doesn't contain a dictionary. So just checking the type solved the issue.

def inject_environment_variables(d):
    if not d:
        return d
    for k, v in d.items():
        if isinstance(v, str):
            d[k] = os.path.expandvars(v)
        elif isinstance(v, dict):

            d[k] = inject_environment_variables(v)
        elif isinstance(v, list):
            for e in v:
                if type(e) == 'dict':
                    d[k] = inject_environment_variables(e)
                else:
                    continue
        return d