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 (pulse) #8268

Merged
merged 4 commits into from
Jan 2, 2024
Merged

Fix mypy errors (pulse) #8268

merged 4 commits into from
Jan 2, 2024

Conversation

Randl
Copy link
Contributor

@Randl Randl commented Jun 29, 2022

Summary

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

Details and comments

There is a set of fixes to comparators which should take object rather than specific type.

The are ~140 errors left:

All error list
qiskit/pulse/builder.py: error: The return type of a generator function should be "Generator" or one of its supertypes  [misc]
qiskit/pulse/builder.py:483: error: Need type annotation for "BUILDER_CONTEXTVAR"  [var-annotated]
qiskit/pulse/builder.py:487: error: Argument 2 to NewType(...) must be subclassable (got "Union[MemorySlot, RegisterSlot]")  [valid-newtype]
qiskit/pulse/builder.py:596: error: Argument 1 to "get" of "dict" has incompatible type "Union[str, AlignmentKind]"; expected "str"  [arg-type]
qiskit/pulse/builder.py:717: error: Incompatible return value type (got "Union[Schedule, List[Schedule]]", expected "Schedule")  [return-value]
qiskit/pulse/builder.py:804: error: Argument 1 to "update" of "MutableMapping" has incompatible type "Dict[ParameterExpression, Union[ParameterExpression, float]]"; expected "SupportsKeysAndGetItem[Parameter, Union[ParameterExpression, float]]"  [arg-type]
qiskit/pulse/builder.py:806: error: Argument 2 to "Call" has incompatible type "Dict[Parameter, Union[ParameterExpression, float]]"; expected "Optional[Dict[ParameterExpression, Union[ParameterExpression, float]]]"  [arg-type]
qiskit/pulse/builder.py:830: error: Argument 1 to "iter" has incompatible type "Union[int, Tuple[int, ...]]"; expected "SupportsIter[Iterator[int]]"  [arg-type]
qiskit/pulse/builder.py:832: error: Incompatible types in assignment (expression has type "Tuple[Union[int, Tuple[int, ...]]]", variable has type "Union[int, Tuple[int, ...]]")  [assignment]
qiskit/pulse/builder.py:1123: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], ContextManager[None]]"; expected "Callable[[], Iterator[<nothing>]]"  [arg-type]
qiskit/pulse/builder.py:1161: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], AlignmentKind]"; expected "Callable[[], Iterator[<nothing>]]"  [arg-type]
qiskit/pulse/builder.py:1199: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], AlignmentKind]"; expected "Callable[[], Iterator[<nothing>]]"  [arg-type]
qiskit/pulse/builder.py:1237: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[int, ParameterExpression]], AlignmentKind]"; expected "Callable[[Union[int, ParameterExpression]], Iterator[<nothing>]]"  [arg-type]
qiskit/pulse/builder.py:1288: error: Argument 1 to "contextmanager" has incompatible type "Callable[[Union[int, ParameterExpression], Callable[[int], float]], AlignmentKind]"; expected "Callable[[Union[int, ParameterExpression], Callable[[int], float]], Iterator[<nothing>]]"  [arg-type]
qiskit/pulse/builder.py:1349: error: Argument 1 to "contextmanager" has incompatible type "Callable[[AlignmentKind], ContextManager[None]]"; expected "Callable[[AlignmentKind], Iterator[<nothing>]]"  [arg-type]
qiskit/pulse/builder.py:1375: error: Argument 1 to "contextmanager" has incompatible type "Callable[[], ContextManager[None]]"; expected "Callable[[], Iterator[<nothing>]]"  [arg-type]
qiskit/pulse/builder.py:1404: error: Argument 1 to "contextmanager" has incompatible type "Callable[[VarArg(Channel)], ContextManager[None]]"; expected "Callable[[VarArg(Channel)], Iterator[<nothing>]]"  [arg-type]
qiskit/pulse/builder.py:1431: error: Argument 1 to "contextmanager" has incompatible type "Callable[[KwArg(Any)], ContextManager[None]]"; expected "Callable[[KwArg(Any)], Iterator[<nothing>]]"  [arg-type]
qiskit/pulse/builder.py:1451: error: Property "transpiler_settings" defined in "_PulseBuilder" is read-only  [misc]
qiskit/pulse/builder.py:1451: error: Argument 2 to "ChainMap" has incompatible type "Mapping[Any, Any]"; expected "MutableMapping[Any, Any]"  [arg-type]
qiskit/pulse/builder.py:1455: error: Property "transpiler_settings" defined in "_PulseBuilder" is read-only  [misc]
qiskit/pulse/builder.py:1458: error: Argument 1 to "contextmanager" has incompatible type "Callable[[KwArg(Any)], ContextManager[None]]"; expected "Callable[[KwArg(Any)], Iterator[<nothing>]]"  [arg-type]
qiskit/pulse/builder.py:1478: error: Property "circuit_scheduler_settings" defined in "_PulseBuilder" is read-only  [misc]
qiskit/pulse/builder.py:1479: error: Argument 2 to "ChainMap" has incompatible type "Mapping[Any, Any]"; expected "MutableMapping[Any, Any]"  [arg-type]
qiskit/pulse/builder.py:1484: error: Property "circuit_scheduler_settings" defined in "_PulseBuilder" is read-only  [misc]
qiskit/pulse/builder.py:1487: error: Argument 1 to "contextmanager" has incompatible type "Callable[[float, VarArg(PulseChannel)], ContextManager[None]]"; expected "Callable[[float, VarArg(PulseChannel)], Iterator[<nothing>]]"  [arg-type]
qiskit/pulse/builder.py:1523: error: Argument 1 to "contextmanager" has incompatible type "Callable[[float, VarArg(PulseChannel), DefaultNamedArg(bool, 'compensate_phase')], ContextManager[None]]"; expected "Callable[[float, VarArg(PulseChannel), DefaultNamedArg(bool, 'compensate_phase')], Iterator[<nothing>]]"  [arg-type]
qiskit/pulse/builder.py:1771: error: Argument 4 to "Acquire" has incompatible type "**Dict[str, Union[Kernel, Discriminator]]"; expected "Optional[RegisterSlot]"  [arg-type]
qiskit/pulse/builder.py:1771: error: Argument 4 to "Acquire" has incompatible type "**Dict[str, Union[Kernel, Discriminator]]"; expected "Optional[Kernel]"  [arg-type]
qiskit/pulse/builder.py:1771: error: Argument 4 to "Acquire" has incompatible type "**Dict[str, Union[Kernel, Discriminator]]"; expected "Optional[Discriminator]"  [arg-type]
qiskit/pulse/builder.py:1771: error: Argument 4 to "Acquire" has incompatible type "**Dict[str, Union[Kernel, Discriminator]]"; expected "Optional[str]"  [arg-type]
qiskit/pulse/builder.py:1775: error: Argument 4 to "Acquire" has incompatible type "**Dict[str, Union[Kernel, Discriminator]]"; expected "Optional[MemorySlot]"  [arg-type]
qiskit/pulse/builder.py:1775: error: Argument 4 to "Acquire" has incompatible type "**Dict[str, Union[Kernel, Discriminator]]"; expected "Optional[Kernel]"  [arg-type]
qiskit/pulse/builder.py:1775: error: Argument 4 to "Acquire" has incompatible type "**Dict[str, Union[Kernel, Discriminator]]"; expected "Optional[Discriminator]"  [arg-type]
qiskit/pulse/builder.py:1775: error: Argument 4 to "Acquire" has incompatible type "**Dict[str, Union[Kernel, Discriminator]]"; expected "Optional[str]"  [arg-type]
qiskit/pulse/builder.py:1977: error: Argument 3 to "call_subroutine" of "_PulseBuilder" has incompatible type "Optional[Dict[Union[ParameterExpression, float], Union[ParameterExpression, float]]]"; expected "Optional[Dict[ParameterExpression, Union[ParameterExpression, float]]]"  [arg-type]
qiskit/pulse/builder.py:2173: error: Argument 1 to "list" has incompatible type "Union[List[int], int]"; expected "Iterable[int]"  [arg-type]
qiskit/pulse/builder.py:2175: error: List item 0 has incompatible type "Union[List[int], int]"; expected "int"  [list-item]
qiskit/pulse/builder.py:2178: error: List comprehension has incompatible type List[MemorySlot]; expected List[StorageLocation]  [misc]
qiskit/pulse/builder.py:2183: error: List item 0 has incompatible type "Union[List[StorageLocation], StorageLocation]"; expected "StorageLocation"  [list-item]
qiskit/pulse/builder.py:2269: error: Argument 1 to "qubit_channels" has incompatible type "Union[int, Iterable[int]]"; expected "int"  [arg-type]
qiskit/pulse/configuration.py:142: error: Argument 1 to "add_lo_range" of "LoConfig" has incompatible type "Union[DriveChannel, MeasureChannel]"; expected "DriveChannel"  [arg-type]
qiskit/pulse/configuration.py:170: error: Missing positional argument "upper_bound" in call to "LoRange"  [call-arg]
qiskit/pulse/filters.py:46: error: Incompatible types in assignment (expression has type "Union[Schedule, ScheduleBlock]", variable has type "Schedule")  [assignment]
qiskit/pulse/filters.py:119: error: Unsupported right operand type for in ("Union[Iterable[Channel], Channel]")  [operator]
qiskit/pulse/filters.py:144: error: Argument 1 to "tuple" has incompatible type "Union[Iterable[ABCMeta], ABCMeta]"; expected "Iterable[Union[type, Tuple[Any, ...]]]"  [arg-type]
qiskit/pulse/filters.py:168: error: "int" object is not iterable  [misc]
qiskit/pulse/instruction_schedule_map.py:306: error: Item "function" of "Union[Schedule, ScheduleBlock, Callable[..., Union[Schedule, ScheduleBlock]]]" has no attribute "metadata"  [union-attr]
qiskit/pulse/instruction_schedule_map.py:307: error: Item "function" of "Union[Schedule, ScheduleBlock, Callable[..., Union[Schedule, ScheduleBlock]]]" has no attribute "metadata"  [union-attr]
qiskit/pulse/instruction_schedule_map.py:371: error: Incompatible return value type (got "Tuple[Any, ...]", expected "Tuple[str]")  [return-value]
qiskit/pulse/instruction_schedule_map.py:408: error: Argument 1 to "tuple" has incompatible type "Union[int, Iterable[int]]"; expected "Iterable[int]"  [arg-type]
qiskit/pulse/instruction_schedule_map.py:410: error: Incompatible return value type (got "Tuple[Union[int, Iterable[int]]]", expected "Tuple[int, ...]")  [return-value]
qiskit/pulse/instructions/acquire.py:93: error: Incompatible return value type (got "Tuple[Any, ...]", expected "Tuple[Union[AcquireChannel, MemorySlot, RegisterSlot]]")  [return-value]
qiskit/pulse/instructions/acquire.py:96: error: Return type "Union[int, ParameterExpression]" of "duration" incompatible with return type "int" in supertype "Instruction"  [override]
qiskit/pulse/instructions/call.py:75: error: Return type "Union[int, ParameterExpression]" of "duration" incompatible with return type "int" in supertype "Instruction"  [override]
qiskit/pulse/instructions/delay.py:67: error: Return type "Union[int, ParameterExpression]" of "duration" incompatible with return type "int" in supertype "Instruction"  [override]
qiskit/pulse/instructions/directives.py:53: error: Incompatible return value type (got "Tuple[Any, ...]", expected "Tuple[Channel]")  [return-value]
qiskit/pulse/instructions/instruction.py:194: error: Argument 1 to "ch_stop_time" of "Instruction" has incompatible type "*Set[Channel]"; expected "List[Channel]"  [arg-type]
qiskit/pulse/instructions/play.py:74: error: Return type "Union[int, ParameterExpression]" of "duration" incompatible with return type "int" in supertype "Instruction"  [override]
qiskit/pulse/library/continuous.py:137: error: Unsupported operand types for - ("complex" and "Tuple[ndarray[Any, Any], ndarray[Any, Any]]")  [operator]
qiskit/pulse/library/continuous.py:137: note: Right operand is of type "Union[ndarray[Any, Any], Tuple[ndarray[Any, Any], ndarray[Any, Any]]]"
qiskit/pulse/library/continuous.py:141: error: Incompatible return value type (got "Tuple[ndarray[Any, Any], Union[complex, float, ndarray[Any, Any]]]", expected "Union[ndarray[Any, Any], Tuple[ndarray[Any, Any], float]]")  [return-value]
qiskit/pulse/library/continuous.py:179: error: Incompatible types in assignment (expression has type "Union[ndarray[Any, Any], Tuple[ndarray[Any, Any], float]]", variable has type "ndarray[Any, dtype[complexfloating[Any, Any]]]")  [assignment]
qiskit/pulse/library/continuous.py:261: error: Unsupported operand types for - ("complex" and "Tuple[ndarray[Any, Any], ndarray[Any, Any]]")  [operator]
qiskit/pulse/library/continuous.py:261: note: Right operand is of type "Union[ndarray[Any, Any], Tuple[ndarray[Any, Any], ndarray[Any, Any]]]"
qiskit/pulse/library/continuous.py:265: error: Incompatible return value type (got "Tuple[ndarray[Any, Any], Union[complex, float, ndarray[Any, Any]]]", expected "Union[ndarray[Any, Any], Tuple[ndarray[Any, Any], float]]")  [return-value]
qiskit/pulse/library/parametric_pulses.py:174: error: Argument "duration" to "gaussian" has incompatible type "Union[int, ParameterExpression]"; expected "int"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:174: error: Argument "amp" to "gaussian" has incompatible type "Union[complex, ParameterExpression]"; expected "complex"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:174: error: Argument "sigma" to "gaussian" has incompatible type "Union[float, ParameterExpression]"; expected "float"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:177: error: Argument 1 to "abs" has incompatible type "Union[complex, ParameterExpression]"; expected "SupportsAbs[float]"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:179: error: Argument 1 to "abs" has incompatible type "Union[complex, ParameterExpression]"; expected "SupportsAbs[float]"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:182: error: Unsupported operand types for >= ("int" and "ParameterExpression")  [operator]
qiskit/pulse/library/parametric_pulses.py:182: note: Left operand is of type "Union[float, ParameterExpression]"
qiskit/pulse/library/parametric_pulses.py:305: error: Argument "duration" to "gaussian_square" has incompatible type "Union[int, ParameterExpression]"; expected "int"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:305: error: Argument "amp" to "gaussian_square" has incompatible type "Union[complex, ParameterExpression]"; expected "complex"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:305: error: Argument "width" to "gaussian_square" has incompatible type "Union[float, ParameterExpression]"; expected "Optional[float]"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:305: error: Argument "sigma" to "gaussian_square" has incompatible type "Union[float, ParameterExpression]"; expected "float"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:309: error: Argument 1 to "abs" has incompatible type "Union[complex, ParameterExpression]"; expected "SupportsAbs[float]"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:311: error: Argument 1 to "abs" has incompatible type "Union[complex, ParameterExpression]"; expected "SupportsAbs[float]"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:314: error: Unsupported operand types for >= ("int" and "ParameterExpression")  [operator]
qiskit/pulse/library/parametric_pulses.py:314: note: Left operand is of type "Union[float, ParameterExpression]"
qiskit/pulse/library/parametric_pulses.py:321: error: Unsupported operand types for > ("int" and "ParameterExpression")  [operator]
qiskit/pulse/library/parametric_pulses.py:321: note: Left operand is of type "Union[float, ParameterExpression]"
qiskit/pulse/library/parametric_pulses.py:325: error: Unsupported operand types for >= ("float" and "ParameterExpression")  [operator]
qiskit/pulse/library/parametric_pulses.py:325: error: Unsupported operand types for <= ("int" and "ParameterExpression")  [operator]
qiskit/pulse/library/parametric_pulses.py:325: error: Unsupported left operand type for >= ("ParameterExpression")  [operator]
qiskit/pulse/library/parametric_pulses.py:325: note: Both left and right operands are unions
qiskit/pulse/library/parametric_pulses.py:331: error: Unsupported operand types for >= ("int" and "ParameterExpression")  [operator]
qiskit/pulse/library/parametric_pulses.py:331: note: Left operand is of type "Union[float, ParameterExpression]"
qiskit/pulse/library/parametric_pulses.py:337: error: Unsupported operand types for <= ("float" and "ParameterExpression")  [operator]
qiskit/pulse/library/parametric_pulses.py:337: note: Both left and right operands are unions
qiskit/pulse/library/parametric_pulses.py:449: error: Argument "duration" to "drag" has incompatible type "Union[int, ParameterExpression]"; expected "int"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:449: error: Argument "amp" to "drag" has incompatible type "Union[complex, ParameterExpression]"; expected "complex"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:449: error: Argument "sigma" to "drag" has incompatible type "Union[float, ParameterExpression]"; expected "float"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:449: error: Argument "beta" to "drag" has incompatible type "Union[float, ParameterExpression]"; expected "float"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:453: error: Argument 1 to "abs" has incompatible type "Union[complex, ParameterExpression]"; expected "SupportsAbs[float]"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:455: error: Argument 1 to "abs" has incompatible type "Union[complex, ParameterExpression]"; expected "SupportsAbs[float]"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:458: error: Unsupported operand types for >= ("int" and "ParameterExpression")  [operator]
qiskit/pulse/library/parametric_pulses.py:458: note: Left operand is of type "Union[float, ParameterExpression]"
qiskit/pulse/library/parametric_pulses.py:466: error: Argument 1 to "__call__" of "_UFunc_Nin1_Nout1" has incompatible type "Union[float, ParameterExpression]"; expected "Union[int, float, complex, str, bytes, generic]"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:477: error: Unsupported operand types for ** ("ParameterExpression" and "int")  [operator]
qiskit/pulse/library/parametric_pulses.py:477: note: Left operand is of type "Union[float, ParameterExpression]"
qiskit/pulse/library/parametric_pulses.py:477: note: Left operand is of type "Union[float, Any]"
qiskit/pulse/library/parametric_pulses.py:485: error: Argument "sigma" to "drag" has incompatible type "Union[float, ParameterExpression]"; expected "float"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:486: error: Argument "beta" to "drag" has incompatible type "Union[float, ParameterExpression]"; expected "float"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:487: error: Argument "amp" to "drag" has incompatible type "Union[complex, ParameterExpression]"; expected "complex"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:547: error: Argument "duration" to "constant" has incompatible type "Union[int, ParameterExpression]"; expected "int"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:547: error: Argument "amp" to "constant" has incompatible type "Union[complex, ParameterExpression]"; expected "complex"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:550: error: Argument 1 to "abs" has incompatible type "Union[complex, ParameterExpression]"; expected "SupportsAbs[float]"  [arg-type]
qiskit/pulse/library/parametric_pulses.py:552: error: Argument 1 to "abs" has incompatible type "Union[complex, ParameterExpression]"; expected "SupportsAbs[float]"  [arg-type]
qiskit/pulse/library/pulse.py:115: error: Argument "program" to "draw" has incompatible type "Pulse"; expected "Union[Waveform, ParametricPulse, SymbolicPulse, Schedule, ScheduleBlock]"  [arg-type]
qiskit/pulse/library/samplers/decorators.py:244: error: Incompatible return value type (got "ndarray[Any, dtype[complexfloating[Any, Any]]]", expected "Waveform")  [return-value]
qiskit/pulse/library/symbolic_pulses.py:76: error: Item "complex" of "Union[Any, complex]" has no attribute "expand"  [union-attr]
qiskit/pulse/library/waveform.py:121: error: "Pulse" has no attribute "samples"  [attr-defined]
qiskit/pulse/library/waveform.py:122: error: "Pulse" has no attribute "samples"  [attr-defined]
qiskit/pulse/macros.py:81: error: Item "Instruction" of "Union[Instruction, Any]" has no attribute "channel"  [union-attr]
qiskit/pulse/macros.py:85: error: Invalid index type "Union[int, ParameterExpression]" for "Dict[int, int]"; expected type "int"  [index]
qiskit/pulse/parameter_manager.py:149: error: "Schedule" has no attribute "_Schedule__children"  [attr-defined]
qiskit/pulse/parameter_manager.py:198: error: Argument 1 to "_assign_parameter_expression" of "ParameterSetter" has incompatible type "Union[int, ParameterExpression]"; expected "ParameterExpression"  [arg-type]
qiskit/pulse/parser.py:138: error: Incompatible return value type (got "PulseExpression", expected "Union[complex, Expression]")  [return-value]
qiskit/pulse/parser.py:287: error: "expr" has no attribute "n"  [attr-defined]
qiskit/pulse/parser.py:288: error: "float" not callable  [operator]
qiskit/pulse/schedule.py:157: error: "Schedule" object is not iterable  [misc]
qiskit/pulse/schedule.py:157: error: "Instruction" object is not iterable  [misc]
qiskit/pulse/transforms/alignments.py:143: error: Argument 1 to "ch_start_time" of "Instruction" has incompatible type "Channel"; expected "List[Channel]"  [arg-type]
qiskit/pulse/transforms/alignments.py:149: error: Argument 1 to "ch_start_time" of "Instruction" has incompatible type "Channel"; expected "List[Channel]"  [arg-type]
qiskit/pulse/transforms/alignments.py:155: error: Argument 1 to "ch_start_time" of "Instruction" has incompatible type "*Set[Channel]"; expected "List[Channel]"  [arg-type]
qiskit/pulse/transforms/alignments.py:213: error: Argument 1 to "ch_start_time" of "Instruction" has incompatible type "Channel"; expected "List[Channel]"  [arg-type]
qiskit/pulse/transforms/alignments.py:213: error: Argument 1 to "ch_stop_time" of "Instruction" has incompatible type "Channel"; expected "List[Channel]"  [arg-type]
qiskit/pulse/transforms/alignments.py:222: error: Unexpected keyword argument "inplace" for "shift" of "Instruction"  [call-arg]
qiskit/pulse/instructions/instruction.py:148: note: "shift" of "Instruction" defined here
qiskit/pulse/transforms/alignments.py:223: error: Unexpected keyword argument "inplace" for "insert" of "Instruction"  [call-arg]
qiskit/pulse/instructions/instruction.py:164: note: "insert" of "Instruction" defined here
qiskit/pulse/transforms/alignments.py:225: error: Unexpected keyword argument "inplace" for "insert" of "Instruction"  [call-arg]
qiskit/pulse/instructions/instruction.py:164: note: "insert" of "Instruction" defined here
qiskit/pulse/transforms/alignments.py:227: error: Incompatible return value type (got "Union[Schedule, Instruction]", expected "Schedule")  [return-value]
qiskit/pulse/transforms/alignments.py:373: error: Argument "context_params" to "__init__" of "AlignmentKind" has incompatible type "Tuple[Union[int, ParameterExpression], Callable[..., Any]]"; expected "Tuple[Union[ParameterExpression, float], ...]"  [arg-type]
qiskit/pulse/transforms/base_transforms.py:49: error: Argument 1 to "flatten" has incompatible type "Union[Schedule, ScheduleBlock]"; expected "Schedule"  [arg-type]
qiskit/pulse/transforms/base_transforms.py:63: error: Argument 1 to "list" has incompatible type "Union[Union[Tuple[int, Instruction], Instruction], Iterable[Union[Tuple[int, Instruction], Instruction]]]"; expected "Iterable[Union[Tuple[int, Instruction], Instruction]]"  [arg-type]

There are multiple errors due to constructing with *args and **kwargs. mypy seem to sttruggle with those.
Another chunk of errors is due to the fact that Union[int, ParameterExpression] is appearing in different places where the experssion is considered to be int. I'm not sure whether it is annotation error, some runtime guaraties, or just type error. Example of those can be found in qiskit/pulse/library/parametric_pulses.py.

@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

@HuangJunye HuangJunye added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jun 29, 2022
@1ucian0 1ucian0 added the mypy Work related to support improving type hints in Qiskti code label Mar 30, 2023
@Randl Randl requested a review from wshanks as a code owner April 5, 2023 12:35
@coveralls
Copy link

coveralls commented Apr 5, 2023

Pull Request Test Coverage Report for Build 5713459561

  • 249 of 256 (97.27%) changed or added relevant lines in 25 files are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.02%) to 85.902%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/pulse/channels.py 8 9 88.89%
qiskit/pulse/transforms/canonicalization.py 9 10 90.0%
qiskit/pulse/transforms/dag.py 8 9 88.89%
qiskit/pulse/library/parametric_pulses.py 17 19 89.47%
qiskit/pulse/library/pulse.py 7 9 77.78%
Files with Coverage Reduction New Missed Lines %
qiskit/pulse/library/parametric_pulses.py 1 47.4%
crates/qasm2/src/lex.rs 3 91.65%
Totals Coverage Status
Change from base Build 5684162640: 0.02%
Covered Lines: 73110
Relevant Lines: 85109

💛 - Coveralls

qiskit/pulse/builder.py Outdated Show resolved Hide resolved
@Randl
Copy link
Contributor Author

Randl commented Oct 19, 2023

Not sure why I get TypeError: unsupported operand type(s) for |: 'type' and 'NoneType' even thought there is future import there

@coveralls
Copy link

coveralls commented Nov 5, 2023

Pull Request Test Coverage Report for Build 7389820561

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 87.529%

Totals Coverage Status
Change from base Build 7389197335: 0.02%
Covered Lines: 59291
Relevant Lines: 67739

💛 - Coveralls

@Randl
Copy link
Contributor Author

Randl commented Nov 26, 2023

ping @eggerdj @kevinsung

Copy link
Contributor

@kevinsung kevinsung left a comment

Choose a reason for hiding this comment

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

Thanks! Sorry this took so long. LGTM with one comment.

qiskit/pulse/builder.py Outdated Show resolved Hide resolved
@Randl
Copy link
Contributor Author

Randl commented Dec 22, 2023

Ping @eggerdj @wshanks

@wshanks wshanks added this pull request to the merge queue Jan 2, 2024
Merged via the queue into Qiskit:main with commit c15bea5 Jan 2, 2024
13 checks passed
@wshanks
Copy link
Contributor

wshanks commented Jan 4, 2024

@Randl You might be interested to know that this PR added a typing usage added in Python 3.11 but our requirements only had typing_extensions; python_version<3.11. We didn't catch that because on PRs we only run 3.8 and 3.12 tests. #11487 installs typing_extensions unconditionally, so no other action is needed now and this issue shouldn't happen again.

ShellyGarion pushed a commit to ShellyGarion/qiskit-terra that referenced this pull request Jan 18, 2024
* Fix pulse mypy errors

* Fix pulse mypy errors

* Fix kwargs type definition

---------

Co-authored-by: Will Shanks <willshanks@us.ibm.com>
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

7 participants