Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix nested quotation mark issue of chess env - #178

Open
dingyuan-shi wants to merge 1 commit into
TextArena:mainfrom
dingyuan-shi:fix_bug_chess
Open

fix nested quotation mark issue of chess env#178
dingyuan-shi wants to merge 1 commit into
TextArena:mainfrom
dingyuan-shi:fix_bug_chess

Conversation

@dingyuan-shi

Copy link
Copy Markdown

In line 62 of the Chess env, the nested quotation mark will incur the module import exception as below:

  File "/usr/local/lib/python3.11/dist-packages/textarena/envs/Chess/env.py", line 62
    if self.show_valid: message+=f"\nValid moves: {', '.join([f'[{move.uci()}]' for move in self.state.game_state["board"].legal_moves])}"# show the valid moves
                                                                                                                   ^^^^^
SyntaxError: f-string: unmatched '['

This merge request fix this issue.

@borgr

borgr commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Ready to merge. This is a real import-time SyntaxError on Python 3.10/3.11 (the repo's requires-python is >=3.10); same-quote nesting inside an f-string only became legal in 3.12 (PEP 701), so every Chess variant currently fails to import on supported versions. Swapping the inner quotes to 'board' is the minimal correct fix, and the lookalike on the line just above is inside a # comment so it's correctly left untouched. Good catch.

@borgr

borgr commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Verified. Without this, textarena/envs/Chess/env.py raises SyntaxError: f-string: unmatched '[' on import under Python 3.11 — the show_valid line nests double-quoted game_state["board"] inside a double-quoted f-string, so Chess-v0 can't be instantiated at all on 3.11. De-nesting to 'board' fixes it: the module imports and Chess-v0 resets/observes/steps cleanly with the valid-moves line rendering.

LGTM, recommend merge.

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.

2 participants