Skip to content

Code not working in Python 3.14 but works in previous python versions #3121

@bashirmindee

Description

@bashirmindee

🐛 Bug

Description

code not working in python 3.14

Checklist

  • I checked on the latest version of Hydra
  • I created a minimal repro (See this for tips).

To reproduce

** Minimal Code/Config snippet to reproduce **

# run the code like this: python script.py
import hydra

@hydra.main()
def main(cfg) -> None:
    pass

main()

** Stack trace/error message **

/home/bashir/monolith-api/bla.py:3: UserWarning: 
The version_base parameter is not specified.
Please specify a compatability version level, or None.
Will assume defaults for version 1.1
  @hydra.main()
/home/bashir/monolith-api/bla.py:3: UserWarning: 
config_path is not specified in @hydra.main().
See https://hydra.cc/docs/1.2/upgrades/1.0_to_1.1/changes_to_hydra_main_config_path for more information.
  @hydra.main()
Traceback (most recent call last):
  File "/home/bashir/.pyenv/versions/3.14-dev/lib/python3.14/argparse.py", line 1744, in _check_help
    formatter._expand_help(action)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/home/bashir/.pyenv/versions/3.14-dev/lib/python3.14/argparse.py", line 661, in _expand_help
    if '%' not in help_string:
       ^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'LazyCompletionHelp' is not a container or iterable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/bashir/monolith-api/bla.py", line 7, in <module>
    main()
    ~~~~^^
  File "/home/bashir/monolith-api/venv314dev/lib/python3.14/site-packages/hydra/main.py", line 85, in decorated_main
    args_parser = get_args_parser()
  File "/home/bashir/monolith-api/venv314dev/lib/python3.14/site-packages/hydra/_internal/utils.py", line 547, in get_args_parser
    parser.add_argument(
    ~~~~~~~~~~~~~~~~~~~^
        "--shell-completion",
        ^^^^^^^^^^^^^^^^^^^^^
    ...<2 lines>...
        help=LazyCompletionHelp(),  # type: ignore
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/bashir/.pyenv/versions/3.14-dev/lib/python3.14/argparse.py", line 1558, in add_argument
    self._check_help(action)
    ~~~~~~~~~~~~~~~~^^^^^^^^
  File "/home/bashir/.pyenv/versions/3.14-dev/lib/python3.14/argparse.py", line 1746, in _check_help
    raise ValueError('badly formed help string') from exc
ValueError: badly formed help string```

## Expected Behavior
I expected nothing to happen because this script does nothing.
This is the behavior it does in Python3.13 (which is correct).
Only in Python 3.14 it fails

## System information
- **Hydra Version** :  hydra-core-1.3.2
- **Python version** : 3.14.2
- **Virtual environment type and version** : using pyenv I create a python venv
- **Operating system** : Linux Ubuntu 22.04

## Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions