Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make pathlib.Path a first citizen by adding default converter #43

Closed
zhuoqiang opened this issue Apr 18, 2018 · 4 comments
Closed

make pathlib.Path a first citizen by adding default converter #43

zhuoqiang opened this issue Apr 18, 2018 · 4 comments

Comments

@zhuoqiang
Copy link

if object of type pathlib.Path is used as function argument, clize will complain:

ValueError: Cannot find value converter for default value PosixPath('/foo/bar'). Please specify one as an annotation.
If the default value's type should be used to convert the value, make sure it is decorated with clize.parser.value_converter()

how about add the converter in clize by default? Many of the standard lib in Python3 already changed to support pathlib

@epsy
Copy link
Owner

epsy commented Apr 20, 2018

Good call: pathlib is included in Python, and as a bonus it is the way forward in dealing with paths in Python.

After briefly looking at the documentation, it looks like adding pathlib.PurePath as a key to the default converters table should be the best option. If a user wants to force a specific flavor, they must be able to specify one of the platform-specific types as converters.

@zhuoqiang
Copy link
Author

It would be great if file path validation could also be specified in requirment, like click

http://click.pocoo.org/5/arguments/#file-path-arguments

@epsy
Copy link
Owner

epsy commented Apr 21, 2018

converters.file already does path checking, but gives you a context manager to open the file instead of a path object. Do you have a use case for validating a path and returning the path?

@Shir0kamii
Copy link
Contributor

This issue is solved with #47

@epsy epsy closed this as completed Jun 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants