pypa / pipfile

Other
3.24k stars 145 forks source link

AttributeError while using inject_environment_variables function #133

Open djsam113 opened 3 years ago

djsam113 commented 3 years ago

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