Skip to content

Print dictionaries that contain set values - #741

Open
ibondarenko1 wants to merge 1 commit into
google:masterfrom
ibondarenko1:fix/fire-cpu-correctness-20261201
Open

ibondarenko1 wants to merge 1 commit into
google:masterfrom
ibondarenko1:fix/fire-cpu-correctness-20261201

Conversation

@ibondarenko1

Copy link
Copy Markdown

Summary

Python Fire supports sets and frozensets as values, but a dictionary returned
by a command is classified as a command group when one of its values is a set
or frozenset. Fire then prints a GROUPS help page instead of the command's
result.

value_types.IsSimpleGroup() already accepts nested lists and dictionaries.
Add sets and frozensets to the same output path.

Reproduction

import fire


def result():
    return {'items': {1}}


fire.Fire(result, command=[])

On the base revision, this prints a GROUPS help page listing items. With the patch it prints items: {1}. A list value prints items: [1, 2] on both revisions.

Testing

  • python -m pytest -q fire/core_test.py - 30 passed.
  • python -m pytest -q fire/parser_test.py fire/helptext_test.py - 61 passed.
  • pylint fire/value_types.py fire/core_test.py - 10.00/10.
  • Full suite - 266 passed. The same eight Windows/Python 3.13 test-environment
    failures occur on the unmodified base (temporary-file reopening and an
    invalid \p regex escape in an existing assertion).

Fixes #740.

Signed-off-by: Ievgen (Jack) Bondarenko <ibondarenko@student.sierracollege.edu>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fire prints help for a command result containing a set

1 participant