|
92 | 92 | from gettext import gettext as _, ngettext |
93 | 93 |
|
94 | 94 |
|
95 | | -def _callable(obj): |
96 | | - return hasattr(obj, '__call__') or hasattr(obj, '__bases__') |
97 | | - |
98 | | - |
99 | 95 | SUPPRESS = '==SUPPRESS==' |
100 | 96 |
|
101 | 97 | OPTIONAL = '?' |
@@ -1286,13 +1282,13 @@ def add_argument(self, *args, **kwargs): |
1286 | 1282 |
|
1287 | 1283 | # create the action object, and add it to the parser |
1288 | 1284 | action_class = self._pop_action_class(kwargs) |
1289 | | - if not _callable(action_class): |
| 1285 | + if not callable(action_class): |
1290 | 1286 | raise ValueError('unknown action "%s"' % (action_class,)) |
1291 | 1287 | action = action_class(**kwargs) |
1292 | 1288 |
|
1293 | 1289 | # raise an error if the action type is not callable |
1294 | 1290 | type_func = self._registry_get('type', action.type, action.type) |
1295 | | - if not _callable(type_func): |
| 1291 | + if not callable(type_func): |
1296 | 1292 | raise ValueError('%r is not callable' % (type_func,)) |
1297 | 1293 |
|
1298 | 1294 | # raise an error if the metavar does not match the type |
@@ -2240,7 +2236,7 @@ def _get_values(self, action, arg_strings): |
2240 | 2236 |
|
2241 | 2237 | def _get_value(self, action, arg_string): |
2242 | 2238 | type_func = self._registry_get('type', action.type, action.type) |
2243 | | - if not _callable(type_func): |
| 2239 | + if not callable(type_func): |
2244 | 2240 | msg = _('%r is not callable') |
2245 | 2241 | raise ArgumentError(action, msg % type_func) |
2246 | 2242 |
|
|
0 commit comments