Skip to content

Optional type args are mistyped in help #508

Description

@impredicative

Type annotations that use typing.Optional are incorrectly documented when showing help.

Example 1

from typing import Optional

import fire

def main(arg: Optional[str] = 'something'):
    """Do something with arg."""


if __name__ == '__main__':
    fire.Fire(main)

The corresponding help output is:

INFO: Showing help with the command 'firetest.py -- --help'.

NAME
    firetest.py - Do something with arg.

SYNOPSIS
    firetest.py <flags>

DESCRIPTION
    Do something with arg.

FLAGS
    -a, --arg=ARG
        Type: Optional
        Default: 'something'

Here, Type: Optional is totally incorrect. It should be Optional[str]. My use of str is just an example and it can be anything.

Example 2

from typing import Optional

import fire


def main(arg: Optional[str] = None):
    """Do something with arg."""


if __name__ == '__main__':
    fire.Fire(main)

The corresponding help output is:

INFO: Showing help with the command 'firetest.py -- --help'.

NAME
    firetest.py - Do something with arg.

SYNOPSIS
    firetest.py <flags>

DESCRIPTION
    Do something with arg.

FLAGS
    -a, --arg=ARG
        Type: Optional[Optional]
        Default: None

Here, Type: Optional[Optional] is even more incorrect. It should be Optional[str]. My use of str is just an example and it can be anything.

Activity

  1. dbieber commented on Apr 30, 2024

    @dbieber
    Collaborator

    Thanks for reporting this. Looks like a bug to me. Next steps are to add a test case and identify and resolve the issue.

  2. Jemeljanov commented on May 22, 2024

    @Jemeljanov

    Hi @dbieber,

    I submitted pr #513 to solve this bug and added tests, please let me know your opinion.

  3. Jemeljanov commented on May 28, 2024

    @Jemeljanov

    Hi @dbieber,

    Updated pr #513 to work with the typing package, waiting for your review on the last commit.

  4. impredicative commented on Jul 24, 2024

    @impredicative
    Author

    Given that fire is seemingly dead and this bug really harms the displayed help, I figure it's wise to move away from fire. Any decent LLM, e.g. gpt-4o, can replace the use of fire in a module with a different package, e.g. click.

  5. ronny-rentner commented on Dec 22, 2024

    @ronny-rentner

    Unfortunately I have to agree, fire is dead. So many bugs since many years and nobody cares.

  6. added a commit that references this issue on Feb 24, 2026
    004e65e
  7. added a commit that references this issue on Feb 24, 2026
    68d7604
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

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions