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 (visualization) #8270

Merged
merged 3 commits into from
Mar 30, 2023
Merged

Fix mypy errors (visualization) #8270

merged 3 commits into from
Mar 30, 2023

Conversation

Randl
Copy link
Contributor

@Randl Randl commented Jun 29, 2022

Summary

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

Details and comments

The are ~240 errors left:

All error list
qiskit/visualization/gate_map.py:667: error: Incompatible types in assignment (expression has type "float", variable has type "int")  [assignment]
qiskit/visualization/gate_map.py:670: error: Incompatible types in assignment (expression has type "float", variable has type "int")  [assignment]
qiskit/visualization/gate_map.py:673: error: Incompatible types in assignment (expression has type "float", variable has type "int")  [assignment]
qiskit/visualization/gate_map.py:674: error: Incompatible types in assignment (expression has type "float", variable has type "int")  [assignment]
qiskit/visualization/pulse/interpolation.py:73: error: Argument 1 to "concatenate" has incompatible type "Tuple[List[Any], ndarray[Any, Any], List[Any]]"; expected "Union[_SupportsArray[dtype[Any]], Sequence[_SupportsArray[dtype[Any]]], Sequence[Sequence[_SupportsArray[dtype[Any]]]], Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]], Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]]]]"  [arg-type]
qiskit/visualization/pulse/matplotlib.py:84: error: Incompatible types in assignment (expression has type "Instruction", variable has type "Pulse")  [assignment]
qiskit/visualization/pulse/matplotlib.py:88: error: Incompatible types in assignment (expression has type "List[Pulse]", target has type "Instruction")  [assignment]
qiskit/visualization/pulse/matplotlib.py:189: error: Incompatible types in string interpolation (expression has type "ShiftPhase", placeholder has type "Union[int, float, SupportsFloat]")  [str-format]
qiskit/visualization/pulse/matplotlib.py:192: error: Incompatible types in string interpolation (expression has type "SetPhase", placeholder has type "Union[int, float, SupportsFloat]")  [str-format]
qiskit/visualization/pulse/matplotlib.py:201: error: Incompatible types in string interpolation (expression has type "SetFrequency", placeholder has type "Union[int, float, SupportsFloat]")  [str-format]
qiskit/visualization/pulse/matplotlib.py:462: error: Argument 1 to "update" of "MutableMapping" has incompatible type "OrderedDict[MeasureChannel, EventsOutputChannels]"; expected "SupportsKeysAndGetItem[DriveChannel, EventsOutputChannels]"  [arg-type]
qiskit/visualization/pulse/matplotlib.py:463: error: Argument 1 to "update" of "MutableMapping" has incompatible type "OrderedDict[ControlChannel, EventsOutputChannels]"; expected "SupportsKeysAndGetItem[DriveChannel, EventsOutputChannels]"  [arg-type]
qiskit/visualization/pulse/matplotlib.py:464: error: Argument 1 to "update" of "MutableMapping" has incompatible type "OrderedDict[AcquireChannel, EventsOutputChannels]"; expected "SupportsKeysAndGetItem[DriveChannel, EventsOutputChannels]"  [arg-type]
qiskit/visualization/pulse/matplotlib.py:466: error: Argument 1 to "update" of "MutableMapping" has incompatible type "OrderedDict[SnapshotChannel, EventsOutputChannels]"; expected "SupportsKeysAndGetItem[DriveChannel, EventsOutputChannels]"  [arg-type]
qiskit/visualization/pulse/matplotlib.py:478: error: Invalid index type "Channel" for "OrderedDict[DriveChannel, EventsOutputChannels]"; expected type "DriveChannel"  [index]
qiskit/visualization/pulse/matplotlib.py:480: error: Invalid index type "Channel" for "OrderedDict[SnapshotChannel, EventsOutputChannels]"; expected type "SnapshotChannel"  [index]
qiskit/visualization/pulse/matplotlib.py:481: error: Incompatible return value type (got "Tuple[OrderedDict[DriveChannel, EventsOutputChannels], OrderedDict[DriveChannel, EventsOutputChannels], OrderedDict[SnapshotChannel, EventsOutputChannels]]", expected "Tuple[Dict[Channel, EventsOutputChannels], Dict[Channel, EventsOutputChannels], Dict[Channel, EventsOutputChannels]]")  [return-value]
qiskit/visualization/pulse/matplotlib.py:580: error: No overload variant of "unravel_index" matches argument types "int", "Tuple[int, int]", "str"  [call-overload]
qiskit/visualization/pulse/matplotlib.py:580: note: Possible overload variants:
qiskit/visualization/pulse/matplotlib.py:580: note:     def unravel_index(indices: Union[Union[bool, bool_], int, integer[Any]], shape: Union[SupportsIndex, Sequence[SupportsIndex]], order: Optional[Literal['C', 'F']] = ...) -> Tuple[signedinteger[Any], ...]
qiskit/visualization/pulse/matplotlib.py:580: note:     def unravel_index(indices: Union[_SupportsArray[dtype[Union[bool_, integer[Any]]]], _NestedSequence[_SupportsArray[dtype[Union[bool_, integer[Any]]]]], bool, int, _NestedSequence[Union[bool, int]]], shape: Union[SupportsIndex, Sequence[SupportsIndex]], order: Optional[Literal['C', 'F']] = ...) -> Tuple[ndarray[Any, dtype[signedinteger[Any]]], ...]
qiskit/visualization/pulse/matplotlib.py:584: error: Unsupported operand types for * ("str" and "float")  [operator]
qiskit/visualization/pulse/matplotlib.py:626: error: Missing return statement  [return]
qiskit/visualization/pulse/matplotlib.py:645: error: Missing return statement  [return]
qiskit/visualization/pulse/matplotlib.py:684: error: Incompatible types in assignment (expression has type "str", variable has type "ComplexColors")  [assignment]
qiskit/visualization/pulse/matplotlib.py:685: error: Incompatible return value type (got "ComplexColors", expected "str")  [return-value]
qiskit/visualization/pulse/matplotlib.py:701: error: "Waveform" object is not iterable  [misc]
qiskit/visualization/pulse/matplotlib.py:701: error: "Acquire" object is not iterable  [misc]
qiskit/visualization/pulse/matplotlib.py:721: error: "Waveform" object is not iterable  [misc]
qiskit/visualization/pulse/matplotlib.py:721: error: "Acquire" object is not iterable  [misc]
qiskit/visualization/pulse/matplotlib.py:927: error: Argument 1 to "ch_duration" of "Instruction" has incompatible type "*List[Channel]"; expected "List[Channel]"  [arg-type]
qiskit/visualization/pulse/matplotlib.py:927: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
qiskit/visualization/pulse/matplotlib.py:927: note: Consider using "Sequence" instead, which is covariant
qiskit/visualization/pulse_v2/core.py:232: error: Argument 2 to "set_time_range" of "DrawerCanvas" has incompatible type "Union[int, ParameterExpression, Any]"; expected "float"  [arg-type]
qiskit/visualization/pulse_v2/core.py:288: error: Invalid index type "Channel" for "Dict[Union[DriveChannel, MeasureChannel, ControlChannel, AcquireChannel], Dict[Any, Any]]"; expected type "Union[DriveChannel, MeasureChannel, ControlChannel, AcquireChannel]"  [index]
qiskit/visualization/pulse_v2/core.py:288: error: Incompatible types in assignment (expression has type "float", target has type "Dict[Any, Any]")  [assignment]
qiskit/visualization/pulse_v2/core.py:325: error: Too many arguments for "SnapshotInstruction"  [call-arg]
qiskit/visualization/pulse_v2/core.py:325: error: Incompatible types in assignment (expression has type "SnapshotInstruction", variable has type "BarrierInstruction")  [assignment]
qiskit/visualization/pulse_v2/core.py:325: error: "Instruction" has no attribute "label"  [attr-defined]
qiskit/visualization/pulse_v2/core.py:382: error: Incompatible types in assignment (expression has type "Tuple[float, float]", variable has type "Tuple[int, int]")  [assignment]
qiskit/visualization/pulse_v2/core.py:633: error: Argument 1 to "_bind_coordinate" of "Chart" has incompatible type "ndarray[Any, dtype[Any]]"; expected "Iterator[Coordinate]"  [arg-type]
qiskit/visualization/pulse_v2/core.py:633: note: "ndarray" is missing following "Iterator" protocol member:
qiskit/visualization/pulse_v2/core.py:633: note:     __next__
qiskit/visualization/pulse_v2/core.py:634: error: Argument 1 to "_bind_coordinate" of "Chart" has incompatible type "ndarray[Any, dtype[Any]]"; expected "Iterator[Coordinate]"  [arg-type]
qiskit/visualization/pulse_v2/core.py:634: note: "ndarray" is missing following "Iterator" protocol member:
qiskit/visualization/pulse_v2/core.py:634: note:     __next__
qiskit/visualization/pulse_v2/device_info.py:89: error: Incompatible return value type (got "Union[int, ParameterExpression]", expected "Optional[int]")  [return-value]
qiskit/visualization/pulse_v2/device_info.py:109: error: "Backend" has no attribute "configuration"  [attr-defined]
qiskit/visualization/pulse_v2/device_info.py:110: error: "Backend" has no attribute "defaults"  [attr-defined]
qiskit/visualization/pulse_v2/device_info.py:113: error: "Backend" has no attribute "name"  [attr-defined]
qiskit/visualization/pulse_v2/device_info.py:125: error: Key expression in dictionary comprehension has incompatible type "MeasureChannel"; expected type "DriveChannel"  [misc]
qiskit/visualization/pulse_v2/device_info.py:131: error: Invalid index type "ControlChannel" for "Dict[DriveChannel, Any]"; expected type "DriveChannel"  [index]
qiskit/visualization/pulse_v2/device_info.py:145: error: Argument "channel_frequency_map" to "OpenPulseBackendInfo" has incompatible type "Dict[DriveChannel, Any]"; expected "Optional[Dict[Channel, float]]"  [arg-type]
qiskit/visualization/pulse_v2/drawings.py:104: error: Incompatible types in assignment (expression has type "Union[Channel, List[Channel]]", variable has type "List[Channel]")  [assignment]
qiskit/visualization/pulse_v2/drawings.py:156: error: Argument "xvals" to "__init__" of "ElementaryData" has incompatible type "Union[ndarray[Any, Any], List[Coordinate]]"; expected "ndarray[Any, Any]"  [arg-type]
qiskit/visualization/pulse_v2/drawings.py:157: error: Argument "yvals" to "__init__" of "ElementaryData" has incompatible type "Union[ndarray[Any, Any], List[Coordinate]]"; expected "ndarray[Any, Any]"  [arg-type]
qiskit/visualization/pulse_v2/drawings.py:201: error: Argument "xvals" to "__init__" of "ElementaryData" has incompatible type "Union[ndarray[Any, Any], List[Coordinate]]"; expected "ndarray[Any, Any]"  [arg-type]
qiskit/visualization/pulse_v2/drawings.py:202: error: Argument "yvals" to "__init__" of "ElementaryData" has incompatible type "Union[ndarray[Any, Any], List[Coordinate]]"; expected "ndarray[Any, Any]"  [arg-type]
qiskit/visualization/pulse_v2/drawings.py:245: error: Argument "xvals" to "__init__" of "ElementaryData" has incompatible type "Union[ndarray[Any, Any], List[Coordinate]]"; expected "ndarray[Any, Any]"  [arg-type]
qiskit/visualization/pulse_v2/drawings.py:246: error: Argument "yvals" to "__init__" of "ElementaryData" has incompatible type "Union[ndarray[Any, Any], List[Coordinate]]"; expected "ndarray[Any, Any]"  [arg-type]
qiskit/visualization/pulse_v2/events.py:162: error: Incompatible types in assignment (expression has type "float", variable has type "int")  [assignment]
qiskit/visualization/pulse_v2/events.py:163: error: Incompatible types in assignment (expression has type "float", variable has type "int")  [assignment]
qiskit/visualization/pulse_v2/events.py:164: error: Incompatible types in assignment (expression has type "float", variable has type "int")  [assignment]
qiskit/visualization/pulse_v2/events.py:179: error: Incompatible types in assignment (expression has type "float", variable has type "int")  [assignment]
qiskit/visualization/pulse_v2/events.py:210: error: Incompatible types in assignment (expression has type "float", variable has type "int")  [assignment]
qiskit/visualization/pulse_v2/events.py:246: error: Incompatible types in assignment (expression has type "Union[float, ParameterExpression]", variable has type "float")  [assignment]
qiskit/visualization/pulse_v2/events.py:250: error: Incompatible types in assignment (expression has type "Union[complex, ParameterExpression]", variable has type "float")  [assignment]
qiskit/visualization/pulse_v2/events.py:252: error: Incompatible types in assignment (expression has type "Union[complex, Any]", variable has type "float")  [assignment]
qiskit/visualization/pulse_v2/generators/barrier.py:71: error: List item 0 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/barrier.py:71: error: List item 1 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/barrier.py:72: error: List item 0 has incompatible type "AbstractCoordinate"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/barrier.py:72: error: List item 1 has incompatible type "AbstractCoordinate"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/chart.py:72: error: List item 0 has incompatible type "AbstractCoordinate"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/chart.py:72: error: List item 1 has incompatible type "AbstractCoordinate"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/chart.py:73: error: List item 0 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/chart.py:73: error: List item 1 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/chart.py:108: error: List item 0 has incompatible type "AbstractCoordinate"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/chart.py:109: error: List item 0 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/chart.py:148: error: List item 0 has incompatible type "AbstractCoordinate"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/chart.py:201: error: List item 0 has incompatible type "AbstractCoordinate"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/frame.py:94: error: Value of type "Union[Instruction, List[Instruction]]" is not indexable  [index]
qiskit/visualization/pulse_v2/generators/frame.py:94: error: Item "Instruction" of "Union[Any, Instruction]" has no attribute "channel"  [union-attr]
qiskit/visualization/pulse_v2/generators/frame.py:95: error: List item 0 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/frame.py:142: error: Value of type "Union[Instruction, List[Instruction]]" is not indexable  [index]
qiskit/visualization/pulse_v2/generators/frame.py:142: error: Item "Instruction" of "Union[Any, Instruction]" has no attribute "channel"  [union-attr]
qiskit/visualization/pulse_v2/generators/frame.py:143: error: List item 0 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/frame.py:197: error: Value of type "Union[Instruction, List[Instruction]]" is not indexable  [index]
qiskit/visualization/pulse_v2/generators/frame.py:197: error: Item "Instruction" of "Union[Any, Instruction]" has no attribute "channel"  [union-attr]
qiskit/visualization/pulse_v2/generators/frame.py:198: error: List item 0 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/frame.py:217: error: Value of type "Union[Instruction, List[Instruction]]" is not indexable  [index]
qiskit/visualization/pulse_v2/generators/frame.py:217: error: Item "Instruction" of "Union[Any, Instruction]" has no attribute "channel"  [union-attr]
qiskit/visualization/pulse_v2/generators/frame.py:218: error: List item 0 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/frame.py:275: error: Value of type "Union[Instruction, List[Instruction]]" is not indexable  [index]
qiskit/visualization/pulse_v2/generators/frame.py:275: error: Item "Instruction" of "Union[Any, Instruction]" has no attribute "channel"  [union-attr]
qiskit/visualization/pulse_v2/generators/frame.py:276: error: List item 0 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/frame.py:316: error: Item "Instruction" of "Union[Instruction, List[Instruction]]" has no attribute "__iter__" (not iterable)  [union-attr]
qiskit/visualization/pulse_v2/generators/frame.py:340: error: Value of type "Union[Instruction, List[Instruction]]" is not indexable  [index]
qiskit/visualization/pulse_v2/generators/frame.py:340: error: Item "Instruction" of "Union[Any, Instruction]" has no attribute "channel"  [union-attr]
qiskit/visualization/pulse_v2/generators/frame.py:341: error: List item 0 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/frame.py:342: error: List item 0 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/snapshot.py:75: error: List item 0 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/snapshot.py:124: error: List item 0 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/snapshot.py:125: error: List item 0 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/waveform.py:76: error: Item "Instruction" of "Union[Instruction, List[Instruction]]" has no attribute "channel"  [union-attr]
qiskit/visualization/pulse_v2/generators/waveform.py:76: error: Item "List[Instruction]" of "Union[Instruction, List[Instruction]]" has no attribute "channel"  [union-attr]
qiskit/visualization/pulse_v2/generators/waveform.py:104: error: Item "Instruction" of "Union[Instruction, List[Instruction]]" has no attribute "pulse"  [union-attr]
qiskit/visualization/pulse_v2/generators/waveform.py:104: error: Item "List[Instruction]" of "Union[Instruction, List[Instruction]]" has no attribute "pulse"  [union-attr]
qiskit/visualization/pulse_v2/generators/waveform.py:108: error: Item "Instruction" of "Union[Instruction, List[Instruction]]" has no attribute "pulse"  [union-attr]
qiskit/visualization/pulse_v2/generators/waveform.py:108: error: Item "List[Instruction]" of "Union[Instruction, List[Instruction]]" has no attribute "pulse"  [union-attr]
qiskit/visualization/pulse_v2/generators/waveform.py:109: error: Item "Instruction" of "Union[Instruction, List[Instruction]]" has no attribute "pulse"  [union-attr]
qiskit/visualization/pulse_v2/generators/waveform.py:109: error: Item "List[Instruction]" of "Union[Instruction, List[Instruction]]" has no attribute "pulse"  [union-attr]
qiskit/visualization/pulse_v2/generators/waveform.py:111: error: Item "Instruction" of "Union[Instruction, List[Instruction]]" has no attribute "pulse"  [union-attr]
qiskit/visualization/pulse_v2/generators/waveform.py:111: error: Item "List[Instruction]" of "Union[Instruction, List[Instruction]]" has no attribute "pulse"  [union-attr]
qiskit/visualization/pulse_v2/generators/waveform.py:115: error: Argument "duration" to "_draw_opaque_waveform" has incompatible type "ndarray[Any, Any]"; expected "int"  [arg-type]
qiskit/visualization/pulse_v2/generators/waveform.py:177: error: Item "Instruction" of "Union[Instruction, List[Instruction]]" has no attribute "pulse"  [union-attr]
qiskit/visualization/pulse_v2/generators/waveform.py:177: error: Item "List[Instruction]" of "Union[Instruction, List[Instruction]]" has no attribute "pulse"  [union-attr]
qiskit/visualization/pulse_v2/generators/waveform.py:219: error: Item "Instruction" of "Union[Instruction, List[Instruction]]" has no attribute "channel"  [union-attr]
qiskit/visualization/pulse_v2/generators/waveform.py:219: error: Item "List[Instruction]" of "Union[Instruction, List[Instruction]]" has no attribute "channel"  [union-attr]
qiskit/visualization/pulse_v2/generators/waveform.py:220: error: List item 0 has incompatible type "Union[float, Any]"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/waveform.py:220: error: Item "List[Instruction]" of "Union[Instruction, List[Instruction]]" has no attribute "duration"  [union-attr]
qiskit/visualization/pulse_v2/generators/waveform.py:267: error: Incompatible types in assignment (expression has type "Pulse", variable has type "Waveform")  [assignment]
qiskit/visualization/pulse_v2/generators/waveform.py:268: error: Argument 1 to "arange" has incompatible type "Union[int, ParameterExpression]"; expected "Union[Union[bool, bool_], int, integer[Any]]"  [arg-type]
qiskit/visualization/pulse_v2/generators/waveform.py:353: error: Argument 1 to "concatenate" has incompatible type "Tuple[ndarray[Any, Any], List[Any]]"; expected "Union[_SupportsArray[dtype[Any]], Sequence[_SupportsArray[dtype[Any]]], Sequence[Sequence[_SupportsArray[dtype[Any]]]], Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]], Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]]]]"  [arg-type]
qiskit/visualization/pulse_v2/generators/waveform.py:357: error: Argument 1 to "concatenate" has incompatible type "Tuple[List[Any], ndarray[Any, Any], List[Any]]"; expected "Union[_SupportsArray[dtype[Any]], Sequence[_SupportsArray[dtype[Any]]], Sequence[Sequence[_SupportsArray[dtype[Any]]]], Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]], Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]]]]"  [arg-type]
qiskit/visualization/pulse_v2/generators/waveform.py:426: error: Incompatible return value type (got "List[LineData]", expected "List[Union[LineData, BoxData, TextData]]")  [return-value]
qiskit/visualization/pulse_v2/generators/waveform.py:426: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
qiskit/visualization/pulse_v2/generators/waveform.py:426: note: Consider using "Sequence" instead, which is covariant
qiskit/visualization/pulse_v2/generators/waveform.py:426: note: Perhaps you need a type annotation for "fill_objs"? Suggestion: "List[Union[LineData, BoxData, TextData]]"
qiskit/visualization/pulse_v2/generators/waveform.py:471: error: List item 0 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/waveform.py:471: error: List item 1 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/waveform.py:496: error: List item 0 has incompatible type "float"; expected "Coordinate"  [list-item]
qiskit/visualization/pulse_v2/generators/waveform.py:503: error: Argument 1 to "append" of "list" has incompatible type "TextData"; expected "BoxData"  [arg-type]
qiskit/visualization/pulse_v2/generators/waveform.py:505: error: Incompatible return value type (got "List[BoxData]", expected "List[Union[LineData, BoxData, TextData]]")  [return-value]
qiskit/visualization/pulse_v2/generators/waveform.py:505: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
qiskit/visualization/pulse_v2/generators/waveform.py:505: note: Consider using "Sequence" instead, which is covariant
qiskit/visualization/pulse_v2/generators/waveform.py:505: note: Perhaps you need a type annotation for "fill_objs"? Suggestion: "List[Union[LineData, BoxData, TextData]]"
qiskit/visualization/pulse_v2/generators/waveform.py:565: error: Item "ParametricPulse" of "Union[ParametricPulse, SymbolicPulse]" has no attribute "pulse_type"  [union-attr]
qiskit/visualization/pulse_v2/generators/waveform.py:603: error: Incompatible types in assignment (expression has type "Pulse", variable has type "Waveform")  [assignment]
qiskit/visualization/pulse_v2/generators/waveform.py:604: error: Argument 1 to "arange" has incompatible type "Union[int, ParameterExpression]"; expected "Union[Union[bool, bool_], int, integer[Any]]"  [arg-type]
qiskit/visualization/pulse_v2/generators/waveform.py:608: error: Argument 1 to "arange" has incompatible type "Union[int, ParameterExpression]"; expected "Union[Union[bool, bool_], int, integer[Any]]"  [arg-type]
qiskit/visualization/pulse_v2/generators/waveform.py:609: error: Argument 1 to "zeros" has incompatible type "Union[int, ParameterExpression]"; expected "Union[SupportsIndex, Sequence[SupportsIndex]]"  [arg-type]
qiskit/visualization/pulse_v2/generators/waveform.py:612: error: Argument 1 to "arange" has incompatible type "Union[int, ParameterExpression]"; expected "Union[Union[bool, bool_], int, integer[Any]]"  [arg-type]
qiskit/visualization/pulse_v2/generators/waveform.py:613: error: Argument 1 to "ones" has incompatible type "Union[int, ParameterExpression]"; expected "Union[SupportsIndex, Sequence[SupportsIndex]]"  [arg-type]
qiskit/visualization/pulse_v2/interface.py:411: error: Argument 1 to "set_disable_type" of "DrawerCanvas" has incompatible type "SymbolType"; expected "DataTypes"  [arg-type]
qiskit/visualization/pulse_v2/interface.py:412: error: Argument 1 to "set_disable_type" of "DrawerCanvas" has incompatible type "LabelType"; expected "DataTypes"  [arg-type]
qiskit/visualization/pulse_v2/interface.py:416: error: Argument 1 to "set_disable_type" of "DrawerCanvas" has incompatible type "SymbolType"; expected "DataTypes"  [arg-type]
qiskit/visualization/pulse_v2/interface.py:417: error: Argument 1 to "set_disable_type" of "DrawerCanvas" has incompatible type "LabelType"; expected "DataTypes"  [arg-type]
qiskit/visualization/pulse_v2/interface.py:421: error: Argument 1 to "set_disable_type" of "DrawerCanvas" has incompatible type "LabelType"; expected "DataTypes"  [arg-type]
qiskit/visualization/pulse_v2/interface.py:422: error: Argument 1 to "set_disable_type" of "DrawerCanvas" has incompatible type "LabelType"; expected "DataTypes"  [arg-type]
qiskit/visualization/pulse_v2/interface.py:426: error: Argument 1 to "set_disable_type" of "DrawerCanvas" has incompatible type "LineType"; expected "DataTypes"  [arg-type]
qiskit/visualization/pulse_v2/layouts.py:119: error: Argument "key" to "sorted" has incompatible type "Callable[[Channel], Union[int, ParameterExpression]]"; expected "Callable[[Channel], Union[SupportsDunderLT, SupportsDunderGT]]"  [arg-type]
qiskit/visualization/pulse_v2/layouts.py:119: error: Incompatible return value type (got "Union[int, ParameterExpression]", expected "Union[SupportsDunderLT, SupportsDunderGT]")  [return-value]
qiskit/visualization/pulse_v2/layouts.py:123: error: Argument "key" to "sorted" has incompatible type "Callable[[Channel], Union[int, ParameterExpression]]"; expected "Callable[[Channel], Union[SupportsDunderLT, SupportsDunderGT]]"  [arg-type]
qiskit/visualization/pulse_v2/layouts.py:123: error: Incompatible return value type (got "Union[int, ParameterExpression]", expected "Union[SupportsDunderLT, SupportsDunderGT]")  [return-value]
qiskit/visualization/pulse_v2/layouts.py:127: error: Argument "key" to "sorted" has incompatible type "Callable[[Channel], Union[int, ParameterExpression]]"; expected "Callable[[Channel], Union[SupportsDunderLT, SupportsDunderGT]]"  [arg-type]
qiskit/visualization/pulse_v2/layouts.py:127: error: Incompatible return value type (got "Union[int, ParameterExpression]", expected "Union[SupportsDunderLT, SupportsDunderGT]")  [return-value]
qiskit/visualization/pulse_v2/layouts.py:132: error: Argument "key" to "sorted" has incompatible type "Callable[[Channel], Union[int, ParameterExpression]]"; expected "Callable[[Channel], Union[SupportsDunderLT, SupportsDunderGT]]"  [arg-type]
qiskit/visualization/pulse_v2/layouts.py:132: error: Incompatible return value type (got "Union[int, ParameterExpression]", expected "Union[SupportsDunderLT, SupportsDunderGT]")  [return-value]
qiskit/visualization/pulse_v2/layouts.py:168: error: Argument "key" to "sorted" has incompatible type "Callable[[Channel], Union[int, ParameterExpression]]"; expected "Callable[[Channel], Union[SupportsDunderLT, SupportsDunderGT]]"  [arg-type]
qiskit/visualization/pulse_v2/layouts.py:168: error: Incompatible return value type (got "Union[int, ParameterExpression]", expected "Union[SupportsDunderLT, SupportsDunderGT]")  [return-value]
qiskit/visualization/pulse_v2/layouts.py:171: error: Argument "key" to "sorted" has incompatible type "Callable[[Channel], Union[int, ParameterExpression]]"; expected "Callable[[Channel], Union[SupportsDunderLT, SupportsDunderGT]]"  [arg-type]
qiskit/visualization/pulse_v2/layouts.py:171: error: Incompatible return value type (got "Union[int, ParameterExpression]", expected "Union[SupportsDunderLT, SupportsDunderGT]")  [return-value]
qiskit/visualization/pulse_v2/layouts.py:174: error: Argument "key" to "sorted" has incompatible type "Callable[[Channel], Union[int, ParameterExpression]]"; expected "Callable[[Channel], Union[SupportsDunderLT, SupportsDunderGT]]"  [arg-type]
qiskit/visualization/pulse_v2/layouts.py:174: error: Incompatible return value type (got "Union[int, ParameterExpression]", expected "Union[SupportsDunderLT, SupportsDunderGT]")  [return-value]
qiskit/visualization/pulse_v2/layouts.py:177: error: Argument "key" to "sorted" has incompatible type "Callable[[Channel], Union[int, ParameterExpression]]"; expected "Callable[[Channel], Union[SupportsDunderLT, SupportsDunderGT]]"  [arg-type]
qiskit/visualization/pulse_v2/layouts.py:177: error: Incompatible return value type (got "Union[int, ParameterExpression]", expected "Union[SupportsDunderLT, SupportsDunderGT]")  [return-value]
qiskit/visualization/pulse_v2/layouts.py:231: error: Argument "key" to "sorted" has incompatible type "Callable[[Channel], Union[int, ParameterExpression]]"; expected "Callable[[Channel], Union[SupportsDunderLT, SupportsDunderGT]]"  [arg-type]
qiskit/visualization/pulse_v2/layouts.py:231: error: Incompatible return value type (got "Union[int, ParameterExpression]", expected "Union[SupportsDunderLT, SupportsDunderGT]")  [return-value]
qiskit/visualization/pulse_v2/layouts.py:234: error: Argument "key" to "sorted" has incompatible type "Callable[[Channel], Union[int, ParameterExpression]]"; expected "Callable[[Channel], Union[SupportsDunderLT, SupportsDunderGT]]"  [arg-type]
qiskit/visualization/pulse_v2/layouts.py:234: error: Incompatible return value type (got "Union[int, ParameterExpression]", expected "Union[SupportsDunderLT, SupportsDunderGT]")  [return-value]
qiskit/visualization/pulse_v2/layouts.py:237: error: Argument "key" to "sorted" has incompatible type "Callable[[Channel], Union[int, ParameterExpression]]"; expected "Callable[[Channel], Union[SupportsDunderLT, SupportsDunderGT]]"  [arg-type]
qiskit/visualization/pulse_v2/layouts.py:237: error: Incompatible return value type (got "Union[int, ParameterExpression]", expected "Union[SupportsDunderLT, SupportsDunderGT]")  [return-value]
qiskit/visualization/pulse_v2/layouts.py:240: error: Argument "key" to "sorted" has incompatible type "Callable[[Channel], Union[int, ParameterExpression]]"; expected "Callable[[Channel], Union[SupportsDunderLT, SupportsDunderGT]]"  [arg-type]
qiskit/visualization/pulse_v2/layouts.py:240: error: Incompatible return value type (got "Union[int, ParameterExpression]", expected "Union[SupportsDunderLT, SupportsDunderGT]")  [return-value]
qiskit/visualization/pulse_v2/stylesheet.py:50: error: Signature of "update" incompatible with supertype "MutableMapping"  [override]
qiskit/visualization/pulse_v2/stylesheet.py:50: note:      Superclass:
qiskit/visualization/pulse_v2/stylesheet.py:50: note:          @overload
qiskit/visualization/pulse_v2/stylesheet.py:50: note:          def update(self, SupportsKeysAndGetItem[Any, Any], **kwargs: Any) -> None
qiskit/visualization/pulse_v2/stylesheet.py:50: note:          @overload
qiskit/visualization/pulse_v2/stylesheet.py:50: note:          def update(self, Iterable[Tuple[Any, Any]], **kwargs: Any) -> None
qiskit/visualization/pulse_v2/stylesheet.py:50: note:          @overload
qiskit/visualization/pulse_v2/stylesheet.py:50: note:          def update(self, **kwargs: Any) -> None
qiskit/visualization/pulse_v2/stylesheet.py:50: note:      Subclass:
qiskit/visualization/pulse_v2/stylesheet.py:50: note:          def update(Mapping[str, Any], **kwargs: Any) -> None
qiskit/visualization/pulse_v2/types.py:233: error: String argument 1 "DataType" to NewType(...) does not match variable name "DataTypes"  [misc]
qiskit/visualization/pulse_v2/types.py:236: error: Argument 2 to NewType(...) must be subclassable (got "Union[float, AbstractCoordinate]")  [valid-newtype]
qiskit/visualization/pulse_visualization.py:158: error: Argument "style" to "WaveformDrawer" has incompatible type "Union[PulseStyle, SchedStyle, None]"; expected "PulseStyle"  [arg-type]
qiskit/visualization/pulse_visualization.py:161: error: Incompatible types in assignment (expression has type "ScheduleDrawer", variable has type "WaveformDrawer")  [assignment]
qiskit/visualization/pulse_visualization.py:161: error: Argument "style" to "ScheduleDrawer" has incompatible type "Union[PulseStyle, SchedStyle, None]"; expected "SchedStyle"  [arg-type]
qiskit/visualization/state_visualization.py:1133: error: Argument 1 to "_state_to_latex_ket" has incompatible type "Union[ndarray[Any, Any], Any]"; expected "List[complex]"  [arg-type]
qiskit/visualization/state_visualization.py:1164: error: Incompatible types in assignment (expression has type "float", variable has type "int")  [assignment]
qiskit/visualization/state_visualization.py:1165: error: Incompatible types in assignment (expression has type "float", variable has type "int")  [assignment]
qiskit/visualization/text.py:253: error: Read-only property cannot override read-write property  [misc]
qiskit/visualization/timeline/core.py:164: error: Incompatible types in assignment (expression has type "Union[QuantumCircuit, List[QuantumCircuit]]", variable has type "QuantumCircuit")  [assignment]
qiskit/visualization/timeline/core.py:207: error: Incompatible types in assignment (expression has type "List[Qubit]", variable has type "List[Bits]")  [assignment]
qiskit/visualization/timeline/core.py:207: error: Argument 1 to "list" has incompatible type "List[Clbit]"; expected "Iterable[Qubit]"  [arg-type]
qiskit/visualization/timeline/core.py:434: error: Incompatible types in assignment (expression has type "List[str]", variable has type "Set[str]")  [assignment]
qiskit/visualization/timeline/core.py:445: error: Value of type "Set[str]" is not indexable  [index]
qiskit/visualization/timeline/drawings.py:256: error: List item 0 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/timeline/generators.py:164: error: List item 0 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/timeline/generators.py:164: error: List item 1 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/timeline/generators.py:166: error: Argument "bit" to "BoxData" has incompatible type "Union[Qubit, Clbit]"; expected "Bits"  [arg-type]
qiskit/visualization/timeline/generators.py:182: error: Incompatible types in assignment (expression has type "TextData", variable has type "BoxData")  [assignment]
qiskit/visualization/timeline/generators.py:184: error: Argument "bit" to "TextData" has incompatible type "Union[Qubit, Clbit]"; expected "Bits"  [arg-type]
qiskit/visualization/timeline/generators.py:185: error: Argument "xval" to "TextData" has incompatible type "int"; expected "Coordinate"  [arg-type]
qiskit/visualization/timeline/generators.py:186: error: Argument "yval" to "TextData" has incompatible type "int"; expected "Coordinate"  [arg-type]
qiskit/visualization/timeline/generators.py:270: error: Argument "xval" to "TextData" has incompatible type "float"; expected "Coordinate"  [arg-type]
qiskit/visualization/timeline/generators.py:271: error: Argument "yval" to "TextData" has incompatible type "int"; expected "Coordinate"  [arg-type]
qiskit/visualization/timeline/generators.py:272: error: Argument "bit" to "TextData" has incompatible type "Union[Qubit, Clbit]"; expected "Bits"  [arg-type]
qiskit/visualization/timeline/generators.py:330: error: Argument "xval" to "TextData" has incompatible type "float"; expected "Coordinate"  [arg-type]
qiskit/visualization/timeline/generators.py:331: error: Argument "yval" to "TextData" has incompatible type "int"; expected "Coordinate"  [arg-type]
qiskit/visualization/timeline/generators.py:332: error: Argument "bit" to "TextData" has incompatible type "Union[Qubit, Clbit]"; expected "Bits"  [arg-type]
qiskit/visualization/timeline/generators.py:363: error: List item 0 has incompatible type "AbstractCoordinate"; expected "Coordinate"  [list-item]
qiskit/visualization/timeline/generators.py:363: error: List item 1 has incompatible type "AbstractCoordinate"; expected "Coordinate"  [list-item]
qiskit/visualization/timeline/generators.py:402: error: Argument "xval" to "TextData" has incompatible type "AbstractCoordinate"; expected "Coordinate"  [arg-type]
qiskit/visualization/timeline/generators.py:403: error: Argument "yval" to "TextData" has incompatible type "int"; expected "Coordinate"  [arg-type]
qiskit/visualization/timeline/generators.py:436: error: List item 0 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/timeline/generators.py:436: error: List item 1 has incompatible type "int"; expected "Coordinate"  [list-item]
qiskit/visualization/timeline/generators.py:437: error: List item 0 has incompatible type "float"; expected "Coordinate"  [list-item]
qiskit/visualization/timeline/generators.py:437: error: List item 1 has incompatible type "float"; expected "Coordinate"  [list-item]
qiskit/visualization/timeline/generators.py:438: error: Argument "bit" to "LineData" has incompatible type "Union[Qubit, Clbit]"; expected "Bits"  [arg-type]
qiskit/visualization/timeline/generators.py:473: error: Argument "bits" to "GateLinkData" has incompatible type "List[Union[Qubit, Clbit]]"; expected "List[Bits]"  [arg-type]
qiskit/visualization/timeline/generators.py:473: error: Argument "xval" to "GateLinkData" has incompatible type "int"; expected "Coordinate"  [arg-type]
qiskit/visualization/timeline/interface.py:387: error: Argument 1 to "set_disable_type" of "DrawerCanvas" has incompatible type "LabelType"; expected "DataTypes"  [arg-type]
qiskit/visualization/timeline/layouts.py:144: error: Argument 2 to "zip" has incompatible type "List[str]"; expected "Iterable[int]"  [arg-type]
qiskit/visualization/timeline/stylesheet.py:57: error: Signature of "update" incompatible with supertype "MutableMapping"  [override]
qiskit/visualization/timeline/stylesheet.py:57: note:      Superclass:
qiskit/visualization/timeline/stylesheet.py:57: note:          @overload
qiskit/visualization/timeline/stylesheet.py:57: note:          def update(self, SupportsKeysAndGetItem[Any, Any], **kwargs: Any) -> None
qiskit/visualization/timeline/stylesheet.py:57: note:          @overload
qiskit/visualization/timeline/stylesheet.py:57: note:          def update(self, Iterable[Tuple[Any, Any]], **kwargs: Any) -> None
qiskit/visualization/timeline/stylesheet.py:57: note:          @overload
qiskit/visualization/timeline/stylesheet.py:57: note:          def update(self, **kwargs: Any) -> None
qiskit/visualization/timeline/stylesheet.py:57: note:      Subclass:
qiskit/visualization/timeline/stylesheet.py:57: note:          def update(Mapping[str, Any], **kwargs: Any) -> None
qiskit/visualization/timeline/types.py:142: error: String argument 1 "DataType" to NewType(...) does not match variable name "DataTypes"  [misc]
qiskit/visualization/timeline/types.py:145: error: Argument 2 to NewType(...) must be subclassable (got "Union[float, AbstractCoordinate]")  [valid-newtype]
qiskit/visualization/timeline/types.py:148: error: Argument 2 to NewType(...) must be subclassable (got "Union[Qubit, Clbit]")  [valid-newtype]

There are many errors which should be easy to fiix, e.g., passing integers instead of some more concrete class, or mixing ints and floats.

I'm not sure why those errors appear:

qiskit/visualization/pulse_v2/interface.py:411: error: Argument 1 to "set_disable_type" of "DrawerCanvas" has incompatible type "SymbolType"; expected "DataTypes"  [arg-type]
qiskit/visualization/pulse_v2/interface.py:412: error: Argument 1 to "set_disable_type" of "DrawerCanvas" has incompatible type "LabelType"; expected "DataTypes"  [arg-type]
qiskit/visualization/pulse_v2/interface.py:416: error: Argument 1 to "set_disable_type" of "DrawerCanvas" has incompatible type "SymbolType"; expected "DataTypes"  [arg-type]
qiskit/visualization/pulse_v2/interface.py:417: error: Argument 1 to "set_disable_type" of "DrawerCanvas" has incompatible type "LabelType"; expected "DataTypes"  [arg-type]
qiskit/visualization/pulse_v2/interface.py:421: error: Argument 1 to "set_disable_type" of "DrawerCanvas" has incompatible type "LabelType"; expected "DataTypes"  [arg-type]
qiskit/visualization/pulse_v2/interface.py:422: error: Argument 1 to "set_disable_type" of "DrawerCanvas" has incompatible type "LabelType"; expected "DataTypes"  [arg-type]
qiskit/visualization/pulse_v2/interface.py:426: error: Argument 1 to "set_disable_type" of "DrawerCanvas" has incompatible type "LineType"; expected "DataTypes"  [arg-type]

if DataTypes is the union of all those.

@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:

@HuangJunye HuangJunye added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jun 29, 2022
Comment on lines 111 to 116
@time_range.setter
def time_range(self, new_range: Tuple[int, int]):
"""Update time range to draw."""
self._time_range = new_range

Copy link
Member

Choose a reason for hiding this comment

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

Is this related?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason is this: python/mypy#1465
It may be better just to leave a comment since its a mypy bug, but the change is cheap, so I just went for it (admittedly, I did it before I found out it was a bug)

Copy link
Member

Choose a reason for hiding this comment

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

In that case, I would remove the change. The goal is not to be mypy-clean but to move towards a situation where mypy helps. I'm okay with mypy complaining for something it wont in the future (when the bug gets fixed)

@1ucian0 1ucian0 self-assigned this Feb 6, 2023
@coveralls
Copy link

coveralls commented Feb 6, 2023

Pull Request Test Coverage Report for Build 4550851518

  • 63 of 91 (69.23%) changed or added relevant lines in 9 files are covered.
  • 4 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.02%) to 85.347%

Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit/visualization/pulse/interpolation.py 1 2 50.0%
qiskit/visualization/pulse/matplotlib.py 0 27 0.0%
Files with Coverage Reduction New Missed Lines %
qiskit/circuit/tools/pi_check.py 1 91.23%
qiskit/pulse/library/waveform.py 3 91.67%
Totals Coverage Status
Change from base Build 4548191637: -0.02%
Covered Lines: 67103
Relevant Lines: 78624

💛 - Coveralls

@Randl Randl force-pushed the mypy-16 branch 5 times, most recently from e176e45 to 0c0ec22 Compare February 7, 2023 09:07
@Randl
Copy link
Contributor Author

Randl commented Mar 28, 2023

@1ucian0 anything else required from me here?

Copy link
Member

@1ucian0 1ucian0 left a comment

Choose a reason for hiding this comment

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

I had another pass, some small things here and there. almost done.

@Randl
Copy link
Contributor Author

Randl commented Mar 30, 2023

@1ucian0 done

Copy link
Member

@1ucian0 1ucian0 left a comment

Choose a reason for hiding this comment

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

Thank you!

@1ucian0 1ucian0 added this pull request to the merge queue Mar 30, 2023
Merged via the queue into Qiskit:main with commit 23f10b6 Mar 30, 2023
ElePT pushed a commit to ElePT/qiskit that referenced this pull request Apr 5, 2023
* Fix visualization mypy errors

* Suggested fixes
giacomoRanieri pushed a commit to giacomoRanieri/qiskit-terra that referenced this pull request Apr 16, 2023
* Fix visualization mypy errors

* Suggested fixes
king-p3nguin pushed a commit to king-p3nguin/qiskit-terra that referenced this pull request May 22, 2023
* Fix visualization mypy errors

* Suggested fixes
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
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants