quantumlib / Cirq

A Python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Apache License 2.0
4.24k stars 1.01k forks source link

Update cirq_rigetti to conform to the new mypy standard #6661

Closed NoureldinYosri closed 1 month ago

NoureldinYosri commented 2 months ago

Description of the issue recently mypy released a new version which broke the CI for cirq_regetti ... as a temperary solution we turned off type checks for cirq_regetti https://github.com/quantumlib/Cirq/pull/6662

the CI failure is

cirq-rigetti/cirq_rigetti/quil_input.py:18: error: Cannot find implementation or library stub for module named "pyquil.parser"  [import]
cirq-rigetti/cirq_rigetti/quil_input.py:18: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
cirq-rigetti/cirq_rigetti/quil_input.py:258: error: Item "int" of "Union[Qubit, QubitPlaceholder, FormalArgument, int]" has no attribute "index"  [union-attr]
cirq-rigetti/cirq_rigetti/quil_input.py:269: error: Item "int" of "Union[Qubit, QubitPlaceholder, FormalArgument, int]" has no attribute "index"  [union-attr]
cirq-rigetti/cirq_rigetti/conftest.py:44: error: Missing return statement  [empty-body]
cirq-rigetti/cirq_rigetti/conftest.py:44: note: If the method is meant to be abstract, use @abc.abstractmethod
cirq-rigetti/cirq_rigetti/conftest.py:44: error: Signature of "execute" incompatible with supertype "QAM"  [override]
cirq-rigetti/cirq_rigetti/conftest.py:44: note:      Superclass:
cirq-rigetti/cirq_rigetti/conftest.py:44: note:          def execute(self, executable: Union[EncryptedProgram, Program], memory_map: Optional[Mapping[str, Union[Sequence[int], Sequence[float]]]] = ..., **kwargs: Any) -> Any
cirq-rigetti/cirq_rigetti/conftest.py:44: note:      Subclass:
cirq-rigetti/cirq_rigetti/conftest.py:44: note:          def execute(self, executable: Union[EncryptedProgram, Program]) -> T
cirq-rigetti/cirq_rigetti/conftest.py:47: error: Signature of "run" incompatible with supertype "QAM"  [override]
cirq-rigetti/cirq_rigetti/conftest.py:47: note:      Superclass:
cirq-rigetti/cirq_rigetti/conftest.py:47: note:          def run(self, executable: Union[EncryptedProgram, Program], memory_map: Optional[Mapping[str, Union[Sequence[int], Sequence[float]]]] = ..., **kwargs: Any) -> QAMExecutionResult
cirq-rigetti/cirq_rigetti/conftest.py:47: note:      Subclass:
cirq-rigetti/cirq_rigetti/conftest.py:47: note:          def run(self, program: Union[EncryptedProgram, Program]) -> QAMExecutionResult
cirq-rigetti/cirq_rigetti/conftest.py:58: error: Signature of "native_quil_to_executable" incompatible with supertype "AbstractCompiler"  [override]
cirq-rigetti/cirq_rigetti/conftest.py:58: note:      Superclass:
cirq-rigetti/cirq_rigetti/conftest.py:58: note:          def native_quil_to_executable(self, nq_program: Program, **kwargs: Any) -> Union[EncryptedProgram, Program]
cirq-rigetti/cirq_rigetti/conftest.py:58: note:      Subclass:
cirq-rigetti/cirq_rigetti/conftest.py:58: note:          def native_quil_to_executable(self, nq_program: Program) -> Union[EncryptedProgram, Program]
cirq-rigetti/cirq_rigetti/conftest.py:64: error: Cannot instantiate abstract class "MockQAM" with abstract attribute "execute_with_memory_map_batch"  [abstract]
cirq-rigetti/cirq_rigetti/conftest.py:82: error: Cannot instantiate abstract class "MockCompiler" with abstract attribute "reset"  [abstract]
cirq-rigetti/cirq_rigetti/aspen_device.py:74: error: Argument "isa" to "QCSQuantumProcessor" has incompatible type "qcs_api_client.models.instruction_set_architecture.InstructionSetArchitecture"; expected "qcs_sdk.qpu.isa.InstructionSetArchitecture"  [arg-type]
cirq-rigetti/cirq_rigetti/circuit_sweep_executors.py:65: error: Item "EncryptedProgram" of "Union[EncryptedProgram, Program]" has no attribute "write_memory"  [union-attr]
cirq-rigetti/cirq_rigetti/circuit_sweep_executors.py:65: error: Item "Program" of "Union[EncryptedProgram, Program]" has no attribute "write_memory"  [union-attr]
cirq-rigetti/cirq_rigetti/circuit_sweep_executors.py:125: error: "Program" has no attribute "_instructions"; maybe "instructions", "_add_instruction", or "filter_instructions"?  [attr-defined]
cirq-rigetti/cirq_rigetti/circuit_sweep_executors.py:126: error: "Program" has no attribute "_synthesized_instructions"  [attr-defined]
Found 14 errors in 4 files (checked 1163 source files)
dstrain115 commented 1 month ago

@pavoljuhas Is this solved now, or is this still an issue?

pavoljuhas commented 1 month ago

@pavoljuhas Is this solved now, or is this still an issue?

This is still biting, the latest mypy-1.11.1 finds 97 errors spread around the code base, 79 of them in cirq-core. I am opening a new issue #6705 to continue the work there.