[issue36078] argparse: positional with type=int, default=SUPPRESS raise ValueError

2020-03-16 Thread paul j3
paul j3 added the comment: You are right, this part of the same issue. _get_value() tests '==SUPPRESS==' both for type and choices. -- ___ Python tracker ___

[issue36078] argparse: positional with type=int, default=SUPPRESS raise ValueError

2020-03-16 Thread Tomáš Jeziorský
Tomáš Jeziorský added the comment: I found what appears to be a very similar issue so instead of creating a new issue I will place it here as a comment. The following code: == import argparse parser = argparse.ArgumentParser() parser.add_argument('letter', choices=['a', 'b', 'c'],

[issue36078] argparse: positional with type=int, default=SUPPRESS raise ValueError

2020-01-17 Thread paul j3
paul j3 added the comment: This is a complicated issue that needs a lot of thought and testing before we make any changes. While all Actions have the 'required' attribute, the programmer can only set it for optionals. _get_positional_kwargs() will raise an error if the programmer tries to

[issue36078] argparse: positional with type=int, default=SUPPRESS raise ValueError

2020-01-14 Thread yang
yang added the comment: I ran into the same issue and looked into the code, and found it more complicated than I thought. The more I went on, more issues occur. I wonder if I should open a new issue, but I will first comment here. If you feel like this should be a new issue, I will open one

[issue36078] argparse: positional with type=int, default=SUPPRESS raise ValueError

2019-03-07 Thread paul j3
Change by paul j3 : -- priority: normal -> high ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue36078] argparse: positional with type=int, default=SUPPRESS raise ValueError

2019-02-25 Thread Axel
Axel added the comment: Thanks for so fast looking into this. Good idea to use the workaround with a own conversion function. I'll use this for now. To see what's happening, I tried a own Action with print in __call__ and a own conversion function with printing. I found following workflow:

[issue36078] argparse: positional with type=int, default=SUPPRESS raise ValueError

2019-02-22 Thread paul j3
paul j3 added the comment: By defining a custom 'type' function: def foo(astr): if astr is argparse.SUPPRESS: raise KeyError return astr I get the full traceback 1831 def take_action(action, argument_strings, option_string=None): 1832

[issue36078] argparse: positional with type=int, default=SUPPRESS raise ValueError

2019-02-22 Thread paul j3
paul j3 added the comment: Defaults are handled into two stages. At the start of parsing defaults are added to the Namespace. At the end of parsing intact defaults are evaluated with 'type'. But a nargs='?' positional gets special handling. It matches an empty string, so it is always

[issue36078] argparse: positional with type=int, default=SUPPRESS raise ValueError

2019-02-22 Thread Axel
Change by Axel : -- nosy: +paul.j3 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue36078] argparse: positional with type=int, default=SUPPRESS raise ValueError

2019-02-22 Thread Axel
Axel added the comment: Some more details: The problem is not the order of assignment in take_action: Defaults have been set by: def parse_known_args(self, args=None, namespace=None): ... # add any action defaults that aren't present for action in self._actions:

[issue36078] argparse: positional with type=int, default=SUPPRESS raise ValueError

2019-02-22 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +paul.j3 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue36078] argparse: positional with type=int, default=SUPPRESS raise ValueError

2019-02-22 Thread Axel
New submission from Axel : Example source: from argparse import ArgumentParser, SUPPRESS == parser = ArgumentParser() parser.add_argument('i', nargs='?', type=int, default=SUPPRESS) args = parser.parse_args([]) == results in: error: argument integer: invalid int value: