Skip to content

Is there any way that can transfer path string to pathlib.Path object? #260

Closed
@shichao-wang

Description

@shichao-wang

I have some function that use pathlib.Path as argument, like following script

from pathlib import Path
import fire


def test_fire(path: Path):
    print(type(path))
    print(path)


if __name__ == "__main__":
    fire.Fire(test_fire)

I simply test it with this.

python test_fire.py "/some_path_string"

<class 'str'>
/some_path_string

I expect to get a pathlib.Path object rather than str. Is there any way that I can do this?
Thanks a lot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions