This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author paul.j3
Recipients ascola, eric.smith, paul.j3, rhettinger, xmorel
Date 2020-12-08.18:12:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The pathlib.Path is new since I paid much attention to os matters (I cut my teeth on py2.5).

Off hand it looks like the user could

    import pathlib
    parser.add_argument('-p', type=pathlib.Path)

to convert a string into a Path object.

A custom type function could call this, and apply any desired methods before returning the Path object. But that should be up to the user, not the `argparse` developers.

Importing path specific modules such as pathlib (which in turn has a lot of imports) goes against the attempt to reduce the number of unnecessary imports with modules like argparse.
Reduce the number of imports for argparse

After this diet argparse still imports os, and uses:


I might also note that argparse has only one custom 'type' function, the FileType factory.  Other common type functions like 'int' and 'float' are Python builtin's.  Adding a custom 'bool' (to be used instead of the builtin 'bool') has been rejected.

json, yaml, and datetime types have also been rejected
Date User Action Args
2020-12-08 18:12:30paul.j3setrecipients: + paul.j3, rhettinger, eric.smith, xmorel, ascola
2020-12-08 18:12:30paul.j3setmessageid: <>
2020-12-08 18:12:30paul.j3linkissue42572 messages
2020-12-08 18:12:29paul.j3create