Bug 2356178

Summary: python-cmd2 fails to build with Python 3.14: ValueError: action 'store_true' is not valid for positional arguments
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-cmd2Assignee: Fedora Infrastructure SIG <infra-sig>
Status: NEW --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: apevec, infra-sig, jcapitao, ksurma, ktdreyer, mail, mhroncok, openstack-sig
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2322407    

Description Karolina Surma 2025-03-31 09:52:19 UTC
python-cmd2 fails to build with Python 3.14.0a6.

_________ test_apcustom_no_choices_callables_when_nargs_is_0[kwargs0] __________

kwargs = {'choices_provider': <function fake_func at 0x7fa812f25220>}

    @pytest.mark.parametrize('kwargs', [({'choices_provider': fake_func}), ({'completer': fake_func})])
    def test_apcustom_no_choices_callables_when_nargs_is_0(kwargs):
        with pytest.raises(TypeError) as excinfo:
            parser = Cmd2ArgumentParser()
>           parser.add_argument('name', action='store_true', **kwargs)

tests/test_argparse_custom.py:82: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
cmd2/argparse_custom.py:832: in _add_argument_wrapper
    new_arg = orig_actions_container_add_argument(self, *args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = Cmd2ArgumentParser(prog='pytest', usage=None, description=None, formatter_class=<class 'cmd2.argparse_custom.Cmd2HelpFormatter'>, conflict_handler='error', add_help=True)
args = ('name',)
kwargs = {'dest': 'name', 'option_strings': [], 'required': True}, chars = '-'
dest = 'name', action_name = 'store_true'
action_class = <class 'argparse._StoreTrueAction'>
action = _StoreTrueAction(option_strings=[], dest='name', nargs=0, const=True, default=False, type=None, choices=None, required=True, help=None, metavar=None, deprecated=False)

    def add_argument(self, *args, **kwargs):
        """
        add_argument(dest, ..., name=value, ...)
        add_argument(option_string, option_string, ..., name=value, ...)
        """
    
        # if no positional args are supplied or only one is supplied and
        # it doesn't look like an option string, parse a positional
        # argument
        chars = self.prefix_chars
        if not args or len(args) == 1 and args[0][0] not in chars:
            if args and 'dest' in kwargs:
                raise TypeError('dest supplied twice for positional argument,'
                                ' did you mean metavar?')
            kwargs = self._get_positional_kwargs(*args, **kwargs)
    
        # otherwise, we're adding an optional argument
        else:
            kwargs = self._get_optional_kwargs(*args, **kwargs)
    
        # if no default was supplied, use the parser-level default
        if 'default' not in kwargs:
            dest = kwargs['dest']
            if dest in self._defaults:
                kwargs['default'] = self._defaults[dest]
            elif self.argument_default is not None:
                kwargs['default'] = self.argument_default
    
        # create the action object, and add it to the parser
        action_name = kwargs.get('action')
        action_class = self._pop_action_class(kwargs)
        if not callable(action_class):
            raise ValueError('unknown action {action_class!r}')
        action = action_class(**kwargs)
    
        # raise an error if action for positional argument does not
        # consume arguments
        if not action.option_strings and action.nargs == 0:
>           raise ValueError(f'action {action_name!r} is not valid for positional arguments')
E           ValueError: action 'store_true' is not valid for positional arguments

FAILED tests/test_argparse_custom.py::test_apcustom_no_choices_callables_when_nargs_is_0[kwargs0]
FAILED tests/test_argparse_custom.py::test_apcustom_no_choices_callables_when_nargs_is_0[kwargs1]

https://docs.python.org/3.14/whatsnew/3.14.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.14/fedora-rawhide-x86_64/08837304-python-cmd2/

For all our attempts to build python-cmd2 with Python 3.14, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14/package/python-cmd2/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.14:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14/

Let us know here if you have any questions.

Python 3.14 is planned to be included in Fedora 43.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.14.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.