`pyo3_linter` needs updates following updates to `pyo3` and `pyo3_stub_gen`

Open
#90 0 comments 0 reactions 1 assignee View on GitHub

@asaites is already working on this.

Since Jul 17, 2026.

Assessment

This issue has not been assessed yet.

Description

Since we updated pyo3 and pyo3_stub_gen, there are some rust code changes that the linter needs to learn about.

As an aside, pyo3_stub_gen now catches some of the issues that the linter does, and produces better stubs that enable stubgen to catch some additional issues that we previously needed to rely on the linter to pick up. It may be possible to remove some of those checks, reducing the amount of code we're maintaining for this purpose.

#[stubgen(skip)]

Right now, methods which are marked #[stubgen(skip)] result in an error akin to the following:

ERROR:pyo3_linter:We're probably missing this annotation: program/mod.rs Line(num=263, text='#[gen_stub(skip)]')

Correctly, the linter recognizes that it probably should know something about that annotation, but presently, it doesn't. Likely the right solution is to simply ignore it (within #[pymethod] blocks) and just assume that the method is annotated via another macro, or is intentionally omitted from the stubs.

Main Module Naming

The updated version of pyo3_stub_gen has better understanding now of the module structure, which in practice means we need to adjust the module = quil.$name annotations to module = quil._quil.$name. This was probably what should have been the case, but would have required explicit re-exports for each module. Now, pyo3_stub_gen generates those re-exports for us (which also means we've got correct __all__ in the stubs -- yay!). In any case, the linter had explicit handling for this work-around, but (once the rust code is updated), it won't be necessary (nor correct).

Multiple annotations in #[cfg_attr(...)]

With the newer version of pyo3 it sometimes makes sense to include additional derives on a #[pyclass]. When that's wrapped in a cfg_attr, the linter currently gets confused:

ERROR:pyo3_linter:We're probably missing this annotation: instruction/qubit.rs Line(num=10, text='#[cfg_attr( feature = "python", pyo3::pyclass(module = "quil._quil.instructions", eq, frozen, hash, ord, skip_from_py_object), derive(pyo3::FromPyObject), )]'

This should just be an update to the regex that captures these. As an educated guess, it may simply be that it doesn't account for the trailing comma.

Dominant language
Rust
Stars
10
Forks
2
Avg merge
15h 56m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rigetti/rigetti-pyo3

All issues in rigetti/rigetti-pyo3

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.