Skip to content

Commit 9d278a0

Browse files
TheGupta2012claude
andauthored
Keep pyqasm validate diagnostics on one line (#405)
Rich wraps console output at the detected width (80 when stdout is not a tty). A file path longer than that was broken mid-token across lines, so the reported path was neither copyable nor clickable, and the two CLI tests asserting the absolute path failed whenever the repository sat at a long enough filesystem path. The error console now uses soft_wrap, which disables wrapping and cropping while leaving markup intact. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent a69bfcd commit 9d278a0

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Types of changes:
2323
### Removed
2424

2525
### Fixed
26+
- Fixed `pyqasm validate` wrapping its diagnostics at the console width, which split a file path longer than the width across lines mid-token and left it neither copyable nor clickable. The error console now uses `soft_wrap`, keeping one diagnostic per line.
2627
- Fixed an indirect cycle between gate definitions exhausting the Python stack: `gate a q { b q; }` with `gate b q { a q; }` raised a bare `RecursionError` naming nothing, while the direct case was already reported cleanly. The guard compared the body's gate name against one name, so it saw only a cycle of length one. It now tests membership of the whole expansion chain, and names the path: `Recursive definitions not allowed for gate 'a' (a -> b -> a)`. A gate reached twice down separate paths is a diamond, not a cycle, and still expands. ([#369](https://github.com/qBraid/pyqasm/issues/369))
2728
- Fixed a nested external custom gate counting the depth of the decomposition it skipped, the shape the [#352](https://github.com/qBraid/pyqasm/issues/352) fix did not reach: `unroll(external_gates=["outer"])` on a gate whose body calls another custom gate emitted one statement but reported `depth() == 13`. The suppression flag was assigned and cleared without save-restore, so the inner gate clobbered the outer gate's state in both directions. It is now saved and restored, and the depth is recorded once, from the outermost external gate. ([#367](https://github.com/qBraid/pyqasm/issues/367))
2829

src/pyqasm/cli/validate.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ def validate_qasm(src_paths: list[str], skip_files: Optional[list[str]] = None)
5555

5656
failed_files: list[tuple[str, Exception]] = []
5757

58-
console = Console()
58+
# soft_wrap keeps each diagnostic on one line. Rich otherwise wraps at the
59+
# console width and breaks mid-token, so a file path longer than the width is
60+
# split across lines and stops being copyable or clickable in a terminal.
61+
console = Console(soft_wrap=True)
5962

6063
def validate_qasm_file(file_path: str) -> None:
6164
with open(file_path, "r", encoding="utf-8") as f:

0 commit comments

Comments
 (0)