Bug 2336895 - xonsh fails to build with Python 3.14: ValueError: action 'store_true' is not valid for positional arguments
Summary: xonsh fails to build with Python 3.14: ValueError: action 'store_true' is not...
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: xonsh
Version: 42
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Orphan Owner
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.14
TreeView+ depends on / blocked
 
Reported: 2025-01-10 10:07 UTC by Karolina Surma
Modified: 2025-05-12 12:20 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Karolina Surma 2025-01-10 10:07:11 UTC
xonsh fails to build with Python 3.14.0a3.

Example test failure:
___________________________ test_parser_default_func ___________________________

mocker = <pytest_mock.plugin.MockerFixture object at 0x7fc93855ad00>

    def test_parser_default_func(mocker):
        import xonsh.xontribs as xx
    
        alias = xx.XontribAlias()
    
        def func():
            return True
    
        mocker.patch.object(xx, "xontribs_list", func)
>       assert alias([]) is True

/builddir/build/BUILD/xonsh-0.19.0-build/xonsh-0.19.0/tests/test_cli_utils.py:91: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/builddir/build/BUILD/xonsh-0.19.0-build/BUILDROOT/usr/lib/python3.14/site-packages/xonsh/cli_utils.py:652: in __call__
    self.parser,
/builddir/build/BUILD/xonsh-0.19.0-build/BUILDROOT/usr/lib/python3.14/site-packages/xonsh/cli_utils.py:603: in parser
    self._parser = self.build()
/builddir/build/BUILD/xonsh-0.19.0-build/BUILDROOT/usr/lib/python3.14/site-packages/xonsh/xontribs.py:400: in build
    parser.add_command(xontribs_unload, prog="unload")
/builddir/build/BUILD/xonsh-0.19.0-build/BUILDROOT/usr/lib/python3.14/site-packages/xonsh/cli_utils.py:354: in add_command
    add_args(parser, func, allowed_params=args, doc=doc)
/builddir/build/BUILD/xonsh-0.19.0-build/BUILDROOT/usr/lib/python3.14/site-packages/xonsh/cli_utils.py:192: in add_args
    action = parser.add_argument(*flags, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = ArgParser(prog='xontrib unload', usage=None, description='Unload the given xontribs', formatter_class=<class 'argparse.RawTextHelpFormatter'>, conflict_handler='error', add_help=True)
args = ('verbose',)
kwargs = {'default': False, 'dest': 'verbose', 'help': None, 'option_strings': [], ...}
chars = '-', action_name = 'store_true'
action_class = <class 'argparse._StoreTrueAction'>
action = _StoreTrueAction(option_strings=[], dest='verbose', 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/built_ins/test_xontribs.py::test_xontrib_list - ValueError: acti...
FAILED tests/completers/test_xompletions.py::test_xontrib[xontrib-l-exp0-None]
FAILED tests/completers/test_xompletions.py::test_xontrib[xontrib load--None-exp_part1]
FAILED tests/test_cli_utils.py::test_parser_default_func - ValueError: action...

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/08480352-xonsh/

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

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.

Comment 1 Aoife Moloney 2025-02-26 13:22:05 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 42 development cycle.
Changing version to 42.


Note You need to log in before you can comment on or make changes to this bug.