minted icon indicating copy to clipboard operation
minted copied to clipboard

[python] fix compatibility with Python 3.14

Open ZhongRuoyu opened this issue 2 months ago • 5 comments

argparse.ArgumentParser.__init__ added a new keyword argument color in Python 3.14 ^1. This caused latexminted to break with the following error:

Traceback (most recent call last):
  File "/opt/homebrew/bin/latexminted", line 372, in <module>
    main()
    ~~~~^^
  File "/opt/homebrew/Cellar/texlive/20250308_1/share/texmf-dist/scripts/minted/latexminted-0.5.0-py3-none-any.whl/latexminted/cmdline.py", line 148, in main
    parser.add_command('batch', help='Batch process highlight, styledef, and clean', func=batch)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/texlive/20250308_1/share/texmf-dist/scripts/minted/latexminted-0.5.0-py3-none-any.whl/latexminted/cmdline.py", line 41, in add_command
    parser = self._command_subparsers.add_parser(name, help=help)
  File "/opt/homebrew/Cellar/[email protected]/3.14.0/Frameworks/Python.framework/Versions/3.14/lib/python3.14/argparse.py", line 1271, in add_parser
    parser = self._parser_class(**kwargs)
TypeError: ArgParser.__init__() got an unexpected keyword argument 'color'
system returned with code 256

! Package minted Error: minted v3+ executable is not installed, is not added to
PATH, or is not permitted with restricted shell escape; or MiKTeX is being use
d with -aux-directory or -output-directory without setting a TEXMF_OUTPUT_DIREC
TORY environment variable.

Fix by allowing ArgParser.__init__ to accept unknown keyword arguments and pass them to the superclass.

Fixes https://github.com/gpoore/minted/issues/463.

ZhongRuoyu avatar Oct 12 '25 17:10 ZhongRuoyu

See also: https://github.com/gpoore/minted/issues/463#issuecomment-3393580569

Added attribution to @muzimuzhi who came up with a similar fix before me.

ZhongRuoyu avatar Oct 12 '25 17:10 ZhongRuoyu

It seems the convention in this repo is to update version and changelog files along with the fixing. See for example a4439ac.

I'll defer to @gpoore as I can't decide which version number (minor or patch) I should bump.

ZhongRuoyu avatar Oct 12 '25 19:10 ZhongRuoyu

Confirming, this fix worked for me, thank you very much! Please merge and release a fix version.

fancywriter avatar Oct 16 '25 15:10 fancywriter

Have there been new reviews or findings or can this be merged?

reneleonhardt avatar Nov 26 '25 13:11 reneleonhardt

I’ve been manually applying this patch for several weeks and it works well for me.

brabalan avatar Nov 27 '25 07:11 brabalan

wow, I wasn't sure that me approving the PR would do anything but it's a straightforward fix, so IMO this looks good. I added a comment for an optional addition.

drin avatar Dec 20 '25 15:12 drin