Skip to content

mypy crashes with python 3.14 within argparse #19150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kasium opened this issue May 26, 2025 · 2 comments
Closed

mypy crashes with python 3.14 within argparse #19150

kasium opened this issue May 26, 2025 · 2 comments
Labels

Comments

@kasium
Copy link

kasium commented May 26, 2025

Crash Report

When using python 3.14, mypy crashes right away. This is due the AugmentedHelpFormatter class in mypy which does not accept all arguments of argparse.HelpFormatter. In python 3.14,_get_formatter of argparse will pass prefix_chars which is not supported by AugmentedHelpFormatter.

Proposal: change the constructor of AugmentedHelpFormatter like

class AugmentedHelpFormatter(argparse.RawDescriptionHelpFormatter):
    def __init__(self, prog: str, **kwargs: Any) -> None:
        super().__init__(prog=prog, max_help_position=28, **kwargs)

By the way, the same applies to the color keyword, which is passed as well

Traceback

  File "venv314/lib/python3.14/site-packages/mypy/__main__.py", line 15, in console_entry
    main()
    ~~~~^^
  File "venv314/lib/python3.14/site-packages/mypy/main.py", line 88, in main
    sources, options = process_options(args, stdout=stdout, stderr=stderr, fscache=fscache)
                       ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "venv314/lib/python3.14/site-packages/mypy/main.py", line 1055, in process_options
    parser.add_argument(
    ~~~~~~~~~~~~~~~~~~~^
        "--enable-incomplete-feature",
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<2 lines>...
        help="Enable support of incomplete/experimental features for early preview",
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/data/.pyenv/versions/3.14.0b1/lib/python3.14/argparse.py", line 1562, in add_argument
    formatter = self._get_formatter()
  File "/data/.pyenv/versions/3.14.0b1/lib/python3.14/argparse.py", line 2729, in _get_formatter
    return self.formatter_class(
           ~~~~~~~~~~~~~~~~~~~~^
        prog=self.prog,
        ^^^^^^^^^^^^^^^
        prefix_chars=self.prefix_chars,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        color=self.color,
        ^^^^^^^^^^^^^^^^^
    )
    ^
TypeError: AugmentedHelpFormatter.__init__() got an unexpected keyword argument 'prefix_chars'.)

To Reproduce

  1. setup a python 3.14 environment
  2. run mypy --version

Your Environment

  • Mypy version used: 1.15.0
  • Mypy command-line flags: --version
  • Mypy configuration options from mypy.ini (and other config files): n/a
  • Python version used: 3.1.4.0b1
  • Operating system and version: Linux
@A5rocks
Copy link
Collaborator

A5rocks commented May 26, 2025

This should be fixed by #19020 which should be in mypy 1.16

@A5rocks A5rocks closed this as completed May 26, 2025
@kasium
Copy link
Author

kasium commented May 26, 2025

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants