nodeca/argparse — pull request #45 by hpaulj (2013-01-30 07:37:52+00:00)
Title: Bug in user defined argument type error message

If a user defined argument type function throws an error, the resulting error message includes the whole function `.toString()`, not just the function's name.

I modified the `ArgumentParser._getValue()` error message generator to test whether the `action.type` is a string (i.e. a registered type). If not, it is a function. It tries to deduce the function name (`type.name`), or looks for a `type.displayName` value (user defined). If nothing can be found, use `` (analogous to the `` that Python displays), and attach the original error message.

`test/user_defined_type.js` - mocha tests for `action.type`, including several user defined cases. Some are taken from `test_argparse.py`, some focus on the bug discussed here.