Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mypy errors (compiler) #8259

Closed
wants to merge 1 commit into from
Closed

Fix mypy errors (compiler) #8259

wants to merge 1 commit into from

Conversation

Randl
Copy link
Contributor

@Randl Randl commented Jun 28, 2022

Summary

Following discussion, I'm splitting #8187 by module.

Details and comments


qiskit/compiler/assembler.py:209: error: Module not callable  [operator]
qiskit/compiler/assembler.py:230: error: Module not callable  [operator]
qiskit/compiler/scheduler.py:72: error: "Backend" has no attribute "instruction_schedule_map"  [attr-defined]
qiskit/compiler/scheduler.py:74: error: "Backend" has no attribute "meas_map"  [attr-defined]
qiskit/compiler/scheduler.py:76: error: "Backend" has no attribute "dt"  [attr-defined]
qiskit/compiler/scheduler.py:83: error: "Backend" has no attribute "defaults"  [attr-defined]
qiskit/compiler/scheduler.py:94: error: "Backend" has no attribute "configuration"  [attr-defined]
qiskit/compiler/scheduler.py:97: error: "Backend" has no attribute "configuration"  [attr-defined]
qiskit/compiler/sequencer.py:56: error: "Backend" has no attribute "defaults"  [attr-defined]
qiskit/compiler/sequencer.py:60: error: "Backend" has no attribute "configuration"  [attr-defined]
qiskit/compiler/sequencer.py:64: error: "Backend" has no attribute "configuration"  [attr-defined]
qiskit/compiler/transpiler.py:264: error: Item "QuantumCircuit" of "Union[QuantumCircuit, List[QuantumCircuit]]" has no attribute "__iter__" (not iterable)  [union-attr]
qiskit/compiler/transpiler.py:271: error: Incompatible return value type (got "Union[CircuitInstruction, QuantumCircuit]", expected "Union[QuantumCircuit, List[QuantumCircuit]]")  [return-value]
qiskit/compiler/transpiler.py:316: error: No overload variant of "__getitem__" of "list" matches argument type "str"  [call-overload]
qiskit/compiler/transpiler.py:316: note: Possible overload variants:
qiskit/compiler/transpiler.py:316: note:     def __getitem__(self, SupportsIndex) -> Dict[Any, Any]
qiskit/compiler/transpiler.py:316: note:     def __getitem__(self, slice) -> List[Dict[Any, Any]]
qiskit/compiler/transpiler.py:334: error: Argument 1 to "zip" has incompatible type "Union[QuantumCircuit, List[QuantumCircuit]]"; expected "Iterable[QuantumCircuit]"  [arg-type]
qiskit/compiler/transpiler.py:334: error: Argument 1 to "zip" has incompatible type "Union[QuantumCircuit, List[QuantumCircuit]]"; expected "Iterable[Any]"  [arg-type]
qiskit/compiler/transpiler.py:338: error: Argument 1 to "zip" has incompatible type "Union[QuantumCircuit, List[QuantumCircuit]]"; expected "Iterable[QuantumCircuit]"  [arg-type]
qiskit/compiler/transpiler.py:358: error: Incompatible return value type (got "Union[CircuitInstruction, QuantumCircuit]", expected "Union[QuantumCircuit, List[QuantumCircuit]]")  [return-value]

The first two appear to be some kind of mypy problem: it can't distinguish between function and same named module due to import structure?
The next some are due to the fact that Backend class do not define any attributes, but rather its subclasses do. Finally, some errors are due to type cast mypy misses -- can be solved by explicit cast or changing variable name probably?

@Randl Randl requested a review from a team as a code owner June 28, 2022 14:20
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core

@@ -313,7 +313,7 @@ def callback_func(**kwargs):
)
# Get transpile_args to configure the circuit transpilation job(s)
if coupling_map in unique_transpile_args:
cmap_conf = unique_transpile_args["coupling_map"]
cmap_conf = unique_transpile_args["coupling_map"] # TODO: unique_transpile_args is a list
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like genuine type error, maybe it should be unique_transpile_args[coupling_map]?

@javabster javabster added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jun 28, 2022
@1ucian0 1ucian0 added the mypy Work related to support improving type hints in Qiskti code label Mar 30, 2023
@Randl
Copy link
Contributor Author

Randl commented May 23, 2023

Meanwhile closing since there are no meanigful changes left

@Randl Randl closed this May 23, 2023
@coveralls
Copy link

Pull Request Test Coverage Report for Build 5058128185

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 9 unchanged lines in 4 files lost coverage.
  • Overall coverage increased (+0.09%) to 85.961%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 93.76%
qiskit/transpiler/passes/synthesis/unitary_synthesis.py 1 90.27%
crates/accelerate/src/sabre_swap/mod.rs 2 99.53%
crates/qasm2/src/lex.rs 5 91.65%
Totals Coverage Status
Change from base Build 5050064110: 0.09%
Covered Lines: 71348
Relevant Lines: 83000

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community PR PRs from contributors that are not 'members' of the Qiskit repo mypy Work related to support improving type hints in Qiskti code
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants