Skip to content

Fix missing closing parenthesis in repr() of an untitled Game - #1163

Open
SajalDevX wants to merge 1 commit into
gambitproject:masterfrom
SajalDevX:fix/game-repr-untitled
Open

SajalDevX wants to merge 1 commit into
gambitproject:masterfrom
SajalDevX:fix/game-repr-untitled

Conversation

@SajalDevX

Copy link
Copy Markdown

Issues closed by this PR

None -- small self-found bug; happy to open an issue first if you'd prefer one on record.

Description of the changes in this PR

Game.__repr__ falls back to Game(id=...) when the game has an empty title, but the f-string in game.pxi was missing its closing parenthesis, so the output was unbalanced:

>>> g = gbt.read_efg("tests/test_games/2_player_chance.efg")   # untitled game
>>> repr(g)
'Game(id=1078949216'

This PR adds the missing ), adds regression tests for both the untitled (StrategicGame and ExtensiveGame) and titled forms of the repr in tests/test_game.py, and records the fix in the ChangeLog under the unreleased 17.0.0-beta.2 entry.

How to review this PR

  • The code change is one character in src/pygambit/game.pxi (Game.__repr__).
  • Rebuild pygambit and run pytest tests/test_game.py -k repr; the two test_repr_untitled_game cases fail on master and pass with this change. I also ran pytest tests/test_game.py tests/test_io.py build_support/releases/test_extract_changelog.py and the ruff/flake8/cython-lint pre-commit hooks on the touched files.

`Game.__repr__` falls back to an identity-based form when the game has an
empty title, but the f-string lacked its closing parenthesis, producing
`Game(id=...` instead of `Game(id=...)`.  Add regression tests for the
untitled (strategic and extensive) and titled forms, and a ChangeLog entry.
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.

1 participant