Qiskit / qiskit-ibm-runtime

IBM Client for Qiskit Runtime
https://docs.quantum.ibm.com/api/qiskit-ibm-runtime
Apache License 2.0
160 stars 157 forks source link

Fix type hints in docs for PUBs and improve Sphinx config (Cherry-pick of #2052) #2055

Closed Eric-Arellano closed 1 day ago

Eric-Arellano commented 1 day ago

Closes https://github.com/Qiskit/qiskit-ibm-runtime/issues/1877. We now use EstimatorPubLike and SamplerPubLike for the type hints, rather than Sphinx fully expanding the types into extremely long values shown in #1877.

To fix the type hints, we have to stop using sphinx-autodoc-typehints and instead use autodoc's builtin support for type hints. I didn't realize we were still using sphinx-autodoc-typehints - the other Qiskit projects migrated off a while ago.

This PR also makes some other improvements to align with changes we made in Qiskit Addons & qiskit-ibm-transpiler:

Introduces a regression: type hints for properties

Unfortunately, switching off of sphinx-autodoc-typehints results in https://github.com/Qiskit/documentation/issues/2346. This is a quirk of autosummary that we cannot easily fix. We have a plan to fix it, although realistically won't get to it until Q1 and possibly Q2.

In the meantime, consider repeating some of the type information in the docstring. For example, in

<Attribute id="qiskit_ibm_runtime.EstimatorV2.mode">
    Return the execution mode used by this primitive.

You could rewrite to say

<Attribute id="qiskit_ibm_runtime.EstimatorV2.mode">
    Return the execution mode used by this primitive, either :class:~`.Session` or ~:class:~`.Batch`.