Description
#986 adds 3 type ignores to qrom bloqs to make mypy happy; but its not clear why these issues arise in the first place.
Run check/mypy
qualtran/bloqs/data_loading/qrom.py:56: error: Definition of "controlled" in base class "Bloq" is incompatible with definition in base class "Gate" [misc]
qualtran/bloqs/data_loading/select_swap_qrom.py:65: error: Definition of "controlled" in base class "Bloq" is incompatible with definition in base class "Gate" [misc]
qualtran/bloqs/data_loading/select_swap_qrom.py:253: error: Missing return statement [return]
Found 3 errors in 2 files (checked 436 source files)
This issue is to unblock the PR and track the potential fixes of these mypy issues at a later point.
-
For the first two, there is some nuance going on with multiple inheritance and type-ignores in
controlled
method ofGateWithRegisters
. BothQROM
andSelectSwapQROM
derive fromGateWithRegisters
andQROMBase
(which is a new abstract base class). The only place where thecontrolled
method should come from is theGateWithRegisters
base class; but due to multiple inheritance mypy starts complaining. This issue doesn't arise for all other bloqs that only derive fromGateWithRegisters
. For some reason, having multiple parent classes is making mypy unhappy. -
For the third issue, we have used the pattern of yielding operations without an explicit "return" statement when a function returns a
cirq.OP_TREE
forever in cirq; but for some reason its making mypy unhappy here.
cc @dstrain115