Fix Python type checking errors for PyLance standard mode #2890
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Python code produces numerous type errors in PyLance "standard" mode. This PR reduces pyright errors from 144 to 103 (28% reduction).
Type annotation fixes
Config._config:Dict[str, str]→Dict[str, Any](storesList[str]andOptional[str]values)ShotResult.events:List[Output]→List[Any](containsOutput,StateDump, andstr)noisy_simulator/_noisy_simulator.pyi: Raw strings for LaTeX docstrings (\sum,\otimes)**kwargssignatures:Optional[Dict[str, Any]]→Anyper Python typing specNull safety
StateDumpconstruction with null check onoutput.state_dump()which returnsOptional[StateDumpData]Optional[float]for time attributes in qiskit job classes with assertions documenting invariantsType narrowing for callable pattern
Other fixes
EstimatorResult._is_succeeded: instance method →@staticmethod(called asEstimatorResult._is_succeeded(data))qir,estimate,logical_counts)cast()for_coerce_estimator_paramsreturn typeRemaining issues
~50 errors remain, primarily
reportMissingImportsfor external deps (pyqir, qiskit, IPython) without type stubs.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.