Skip to content

Migrate from poetry to uv#108

Open
PhilReinhold wants to merge 3 commits into
mainfrom
pcrein/poetry-to-uv
Open

Migrate from poetry to uv#108
PhilReinhold wants to merge 3 commits into
mainfrom
pcrein/poetry-to-uv

Conversation

@PhilReinhold
Copy link
Copy Markdown
Collaborator

Convert pyproject.toml to PEP 621 with hatchling backend and a [dependency-groups] dev group. Replace poetry.lock with uv.lock, update CI workflows to use astral-sh/setup-uv, drop the install-poetry Makefile target, and switch the README install command to uv sync.

Convert pyproject.toml to PEP 621 with hatchling backend and a
[dependency-groups] dev group. Replace poetry.lock with uv.lock,
update CI workflows to use astral-sh/setup-uv, drop the install-poetry
Makefile target, and switch the README install command to `uv sync`.
The uv migration pulls in newer mypy (1.4 -> 1.20) and openqasm3/openpulse
(0.5 -> 1.0). The newer AST tightens several signatures (List[QuantumStatement]
where lists were previously List[Statement|Pragma], IndexedIdentifier|Identifier
where Expression was accepted, etc.) and stricter mypy inference flags a few
existing issues. Add casts/asserts to bridge the AST narrowing, fix
ProgramState.body propagation to the AST, give MergeCalStatementsPass a
covariant Sequence parameter, and fix FrameVar passing the FrameType class
instead of an instance to OQFunctionCall.
Two new branches dropped coverage to 99.83%:
- _get_type's None-type guard was a defensive check for mypy; replace with
  a cast since all OQPyExpression subclasses that participate in arithmetic
  set .type during init.
- Add a regression test for indexing a ComplexVar-backed ArrayVar, which
  exercises the new ComplexVar branch in ArrayVar.__getitem__.
@PhilReinhold
Copy link
Copy Markdown
Collaborator Author

Note: this MR also touches src/ to fix newly-surfaced mypy errors

The poetry → uv switch isn't purely a packaging change — it forced a fresh dependency resolution, which pulled in two upgrades that have stricter type
signatures:

  • mypy: 1.4.1 -> 1.20.2

  • openqasm3 / openpulse: 0.5.0 -> 1.0.1

    Together these surfaced 67 new mypy errors, breaking down into three buckets:

    1. openqasm3 1.0 tightened AST signatures. Many AST nodes that used to accept list[Statement | Pragma] now require narrower types — e.g. Box.body:
      list[QuantumStatement], QuantumGate.qubits: list[IndexedIdentifier | Identifier], QuantumReset.qubits: IndexedIdentifier | Identifier,
      SubroutineDefinition.body: list[Statement]. oqpy's ProgramState.body legitimately holds list[Statement | Pragma], so we cast at the construction sites where we
      know the contents are valid.
    2. mypy 1.20 is stricter. It now flags missing type-arg on Iterable, numpy.floating not being assignable to float, implicit Optional defaults (PEP 484), and
      slice being a final class that can't subclass our protocols. Fixed via annotations, float(...) coercions, and adding slice to the AstConvertible union.
    3. One real bug. pulse.py:79 was passing ast.FrameType (the class) instead of ast.FrameType() (an instance) to OQFunctionCall's return_type. This silently
      broke the isinstance(extern.return_type, openpulse_types) check in _make_externs_statements. Caught now by the stricter signature.

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