Skip to content

Breaking change between 3.14 and 3.13 #163105

Not planned
Not planned

Description

@quantum-incongruity

Bug report

import argparse


def main():
    """main function"""
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--arg",
        action=argparse.BooleanOptionalAction,
        type=bool,
        help="Skip if exists",
        default=False,
    )
    args = parser.parse_args()
    print(args)

if __name__ == "__main__":
    main()
$ python3.14 main.py 
Traceback (most recent call last):
  File "/tmp/zzzzz/main.py", line 18, in <module>
    main()
    ~~~~^^
  File "/tmp/zzzzz/main.py", line 7, in main
    parser.add_argument(
    ~~~~~~~~~~~~~~~~~~~^
        "--arg",
        ^^^^^^^^
    ...<3 lines>...
        default=False,
        ^^^^^^^^^^^^^^
    )
    ^
  File "/home/user/.local/share/uv/python/cpython-3.14.6-linux-x86_64-gnu/lib/python3.14/argparse.py", line 1539, in add_argument
    action = action_class(**kwargs)
TypeError: BooleanOptionalAction.__init__() got an unexpected keyword argument 'type'

Works fine with 3.13

$ python3.13 main.py 
Namespace(arg=False)

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Activity

  1. added
    type-bug
    on Dec 3, 2026
  2. quantum-incongruity commented on Dec 3, 2026

    @quantum-incongruity
    Author

    #92248

    #85039

    #103678

    Introducing a breaking change...

  3. gvanrossum commented on Dec 4, 2026

    @gvanrossum
    Member

    This is due an intentional removal of a deprecated feature. The fix in your code is to remove type=bool, since that is implied by BooleanOptionalAction.

  4. quantum-incongruity commented on Dec 4, 2026

    @quantum-incongruity
    Author

    This is due an intentional removal of a deprecated feature. The fix in your code is to remove type=bool, since that is implied by BooleanOptionalAction.

    Yes but what's the goal of making tiny breaking changes like that ? Not sure to understand

  5. gvanrossum commented on Dec 4, 2026

    @gvanrossum
    Member

    Wasn't my decision.

    If you want to know more, start a thread on discuss.python.org.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions