Skip to content

Mypy issues in QROM / SelectSwapQROM #995

Open
@tanujkhattar

Description

@tanujkhattar

#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 of GateWithRegisters. Both QROM and SelectSwapQROM derive from GateWithRegisters and QROMBase (which is a new abstract base class). The only place where the controlled method should come from is the GateWithRegisters base class; but due to multiple inheritance mypy starts complaining. This issue doesn't arise for all other bloqs that only derive from GateWithRegisters. 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions