Skip to content

Any way to circumvent type checking of proxy objects? #38

@syfluqs

Description

@syfluqs

I have a function that needs to lazy return file paths, but I can not actually use the file path since several python standard library functions perform explicit type checking on the arguments. So if I do the following:

lazy_path = lazy_object_proxy.Proxy(lambda: '/home/user')                                       
os.path.join(lazy_path, 'dir')

It results in

/usr/lib/python3.8/posixpath.py in join(a, *p)
     74     will be discarded.  An empty last part will result in a path that
     75     ends with a separator."""
---> 76     a = os.fspath(a)
     77     sep = _get_sep(a)
     78     path = a

TypeError: expected str, bytes or os.PathLike object, not Proxy

Is there any way to bypass this behavior, perhaps with monkey patching or so?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions