Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`stretch` operands in duration arithmetic raise `TypeError: ... 'float' and 'NoneType'`

オープン
#389 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@SAY-5 がすでに取り組んでいます。

2026年8月26日 から。

  • #417 @SAY-5 による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
18/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
compilers

調査の方向性

The float + None error comes from Qasm3ExprEvaluator in src/pyqasm/expressions.py, and stretch declarations are handled in src/pyqasm/visitor.py; unit handling is in DURATION_UNITS in src/pyqasm/maps/expressions.py. Check open pull request #417 first, since it may already cover this. Done means a + s no longer raises a Python TypeError: it either survives symbolically or raises a ValidationError naming the stretch variable and its span, with tests in tests/qasm3/test_timing.py.

索引モデルが issue の本文から書いたものです。

説明

bug error-handling llm-assisted qasm3

Limitation

Duration and stretch types defines
stretch as a duration that resolves at compile time, and
Operations on durations allows a
stretch to be combined with a duration in arithmetic. This is how the spec expresses
padding that absorbs whatever slack a schedule leaves.

pyqasm declares a stretch with a None value and then applies Python arithmetic to it,
producing an uncaught TypeError.

Example QASM failure

import pyqasm

m = pyqasm.loads('''
OPENQASM 3.0;
stretch s;
duration a = 300ns;
duration b = a + s;
''')
m.validate()
TypeError: unsupported operand type(s) for +: 'float' and 'NoneType'

A bare stretch s; declaration and delay[s] q[0]; both work today, so the gap is confined
to arithmetic involving a stretch operand.

Change Requested

  1. Duration expressions containing a stretch operand must not raise a Python TypeError.
  2. Preferred: represent a duration as an affine value (constant_ns, {stretch: coefficient})
    so that a + s, 2 * s, and a + 2 * s are all representable symbolically and can be
    emitted unchanged by dumps().
  3. Minimum acceptable: raise a ValidationError stating that stretch arithmetic is not yet
    supported, naming the stretch variable and its span. The current internal error is the only
    unacceptable outcome.

Implementation Details

  • Duration/stretch declarations are handled in src/pyqasm/visitor.py alongside the other
    classical declarations; the numeric evaluation happens in Qasm3ExprEvaluator
    (src/pyqasm/expressions.py), which is where the float + None occurs.
  • Unit conversion lives in DURATION_UNITS in src/pyqasm/maps/expressions.py; the affine
    representation should normalise the constant part to nanoseconds there, consistent with how
    plain durations are already handled.
  • The affine form composes with the existing box[...] duration validation and delay[...]
    handling, both of which currently expect a plain number — they will need to accept the new
    type or explicitly reject a non-constant duration where a concrete one is required.
  • Full stretch resolution (solving for stretch values against a schedule) is a much larger
    piece of work and is explicitly out of scope here. This issue only asks that stretch
    operands survive expression evaluation.
  • Tests: tests/qasm3/test_timing.py (or the existing delay/box tests) — a + s, 2 * s,
    a + 2 * s, a stretch inside box[...], and a dumps() round-trip.
主要言語
Python
スター
29
フォーク
33
平均マージ
2日 4時間
マージ済み PR(30日)
15

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

qBraid/pyqasm のほかの issue

qBraid/pyqasm の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。