Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
002116b
adding RUF005 and updates
joesho112358 Feb 6, 2026
b6de242
adding RUF015 and updates
joesho112358 Feb 6, 2026
1ca3e19
fixing grid qubit issues
joesho112358 Feb 7, 2026
c24132a
updates to be specific in ruff exclusions
joesho112358 Feb 16, 2026
c5f47af
Merge branch 'main' into ruff-ruf-implementation
joesho112358 Feb 18, 2026
112f595
updates after merge
joesho112358 Feb 18, 2026
e56fc94
undoing some of the weird formatting
joesho112358 Feb 18, 2026
4c4bfaf
undoing some of the weird formatting and fixing tests
joesho112358 Feb 18, 2026
b9213ae
formatting update
joesho112358 Feb 18, 2026
6e133b4
reverting and excluding some lines for ruf005
joesho112358 Feb 18, 2026
2b19990
rearrange static code check exclusions
joesho112358 Feb 18, 2026
7c48804
revert to fix tests
joesho112358 Feb 19, 2026
88e46a8
format fix
joesho112358 Feb 19, 2026
7a1f724
Merge branch 'main' into ruff-ruf-implementation
joesho112358 Feb 21, 2026
53d0056
Merge branch 'main' into ruff-ruf-implementation
joesho112358 Feb 23, 2026
499c5e5
Restore for sake of array shape readability
pavoljuhas Feb 25, 2026
7242482
Replace local one-item list with a string
pavoljuhas Feb 25, 2026
7a96fda
Clean up redundant `iter(iterator)` expressions
pavoljuhas Feb 25, 2026
b72db22
Restore Engine.run without triggering RUF015
pavoljuhas Feb 25, 2026
d5bd313
Adjust type annotation in fsim_gate_family_test
pavoljuhas Feb 25, 2026
fb232e4
Reduce number of ruff-markup comments
pavoljuhas Feb 25, 2026
a356f19
Eliminate throw-away lists and tuples
pavoljuhas Feb 25, 2026
cf64138
Small readability adjustments
pavoljuhas Feb 25, 2026
ef584eb
Points.points is a Sequence, use index lookup for the first point
pavoljuhas Feb 25, 2026
0bd2aa9
Commit uncommitted leftovers
pavoljuhas Feb 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions cirq-core/cirq/_compat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,44 +584,50 @@ def _type_repr_in_deprecated_module():

# this is where the deprecation error should show where the deprecated usage
# has occured, which is this file
_deprecation_origin = ['_compat_test.py:']
_deprecation_origin = '_compat_test.py:'

# see cirq_compat_test_data/__init__.py for the setup code
_fake_a_deprecation_msg = [
f'{old_parent}.fake_a was used but is deprecated',
f'Use {old_parent}.module_a instead',
] + _deprecation_origin
_deprecation_origin,
]

# see cirq_compat_test_data/__init__.py for the setup code
_fake_b_deprecation_msg = [
f'{old_parent}.fake_b was used but is deprecated',
f'Use {old_parent}.module_a.module_b instead',
] + _deprecation_origin
_deprecation_origin,
]

# see cirq_compat_test_data/__init__.py for the setup code
_fake_ab_deprecation_msg = [
f'{old_parent}.module_a.fake_ab was used but is deprecated',
f'Use {old_parent}.module_a.module_b instead',
] + _deprecation_origin
_deprecation_origin,
]

# see cirq_compat_test_data/__init__.py for the setup code
_fake_ops_deprecation_msg = [
f'{old_parent}.fake_ops was used but is deprecated',
'Use cirq.ops instead',
] + _deprecation_origin
_deprecation_origin,
]


# see cirq_compat_test_data/__init__.py for the setup code
_fake_numpy_deprecation_msg = [
f'{old_parent}.fake_numpy was used but is deprecated',
'Use numpy instead',
] + _deprecation_origin
_deprecation_origin,
]

# see cirq_compat_test_data/__init__.py for the setup code
_repeated_child_deprecation_msg = [
f'{old_parent}.repeated_child was used but is deprecated',
f'Use {old_parent}.repeated instead',
] + _deprecation_origin
_deprecation_origin,
]


def _trace_unhandled_exceptions(*args, queue: multiprocessing.Queue, func: Callable):
Expand Down
2 changes: 2 additions & 0 deletions cirq-core/cirq/circuits/circuit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ def test_add_op_tree(circuit_cls) -> None:
a = cirq.NamedQubit('a')
b = cirq.NamedQubit('b')

# ruff: disable[RUF005]
c = circuit_cls()
assert c + [cirq.X(a), cirq.Y(b)] == circuit_cls([cirq.Moment([cirq.X(a), cirq.Y(b)])])

Expand All @@ -362,6 +363,7 @@ def test_radd_op_tree(circuit_cls, gate) -> None:
a = cirq.NamedQubit('a')
b = cirq.NamedQubit('b')

# ruff: disable[RUF005]
c = circuit_cls()
assert [gate(a), cirq.Y(b)] + c == circuit_cls([cirq.Moment([gate(a), cirq.Y(b)])])

Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/circuits/moment.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def with_operation(self, operation: cirq.Operation) -> cirq.Moment:

# Use private variables to facilitate a quick copy.
m = Moment(_flatten_contents=False)
m._operations = self._operations + (operation,)
m._operations = (*self._operations, operation)
m._sorted_operations = None
m._qubit_to_op = {**self._qubit_to_op, **dict.fromkeys(operation.qubits, operation)}

Expand Down
1 change: 1 addition & 0 deletions cirq-core/cirq/circuits/moment_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ def test_add() -> None:
with pytest.raises(ValueError, match='Overlap'):
_ = m1 + m2

# ruff: disable[RUF005]
assert m1 + [[[[cirq.Y(b)]]]] == cirq.Moment(cirq.X(a), cirq.Y(b))
assert m1 + [] == m1
assert m1 + [] is m1
Expand Down
3 changes: 2 additions & 1 deletion cirq-core/cirq/contrib/qasm_import/_lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def __init__(self):
'ARROW',
'EQ',
'AND',
] + list(reserved.values())
*reserved.values(),
]

def t_newline(self, t):
r"""\n+"""
Expand Down
4 changes: 1 addition & 3 deletions cirq-core/cirq/contrib/qasm_import/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,9 +1125,7 @@ def p_if(self, p):
for i, key in enumerate(carg):
v = (val >> i) & 1
conditions.append(sympy.Eq(sympy.Symbol(key), v))
p[0] = [
ops.ClassicallyControlledOperation(conditions=conditions, sub_operation=tuple(p[5])[0])
]
p[0] = [ops.ClassicallyControlledOperation(conditions=conditions, sub_operation=next(p[5]))]

def p_gate_params_multiple(self, p):
"""gate_params : ID ',' gate_params"""
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/contrib/qasm_import/_parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2432,7 +2432,7 @@ def test_all_qelib_gates_unitary_equivalence(
gate = cirq_gate
expected = Circuit()
expected.append(gate.on(*qubits))
imported = list(parsed_qasm.circuit.all_operations())[0].gate
imported = next(parsed_qasm.circuit.all_operations()).gate
U_native = cirq.unitary(gate)
U_import = cirq.unitary(imported)
assert np.allclose(U_import, U_native, atol=1e-8)
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/contrib/quimb/mps_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def apply_op(self, op: Any, axes: Sequence[int], prng: np.random.RandomState):

T = U @ self._M[n] @ self._M[p]

left_inds = tuple(set(T.inds) & set(self._M[n].inds)) + (new_inds[0],)
left_inds = (*set(T.inds).intersection(self._M[n].inds), new_inds[0])
X, Y = T.split(
left_inds,
method=self._simulation_options.method,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ def test_circuits_with_readout_benchmarking_no_qubits_arg_empty_rng(mode: str) -

# When qubits is None, all qubits from input circuits are benchmarked as one group.
assert len(readout_calibration_results) == 1
qlist, result = list(readout_calibration_results.items())[0]
qlist, result = next(iter(readout_calibration_results.items()))
assert isinstance(qlist, tuple)
assert set(qlist) == set(qubits)
assert isinstance(result, SingleQubitReadoutCalibrationResult)
Expand Down Expand Up @@ -412,7 +412,7 @@ def test_deprecated_run_shuffled_with_readout_benchmarking() -> None:
qubits=qubits,
)
assert len(measurements_seed) == len(input_circuits)
qlist, result = list(results_seed.items())[0]
qlist, result = next(iter(results_seed.items()))
assert tuple(qubits) == qlist
for error in result.zero_state_errors.values():
assert 0.08 < error < 0.12
Expand All @@ -430,7 +430,7 @@ def test_deprecated_run_shuffled_with_readout_benchmarking() -> None:
readout_repetitions=readout_repetitions,
qubits=None,
)
qlist_none, _ = list(results_none.items())[0]
qlist_none = next(iter(results_none.keys()))
assert set(qlist_none) == set(qubits)

# Test circuit_repetitions must be > 0
Expand Down
2 changes: 2 additions & 0 deletions cirq-core/cirq/devices/grid_qubit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def test_diagram() -> None:


def test_addition_subtraction() -> None:
# ruff: disable[RUF005]
# GridQubits
assert cirq.GridQubit(1, 2) + (2, 5) == cirq.GridQubit(3, 7)
assert cirq.GridQubit(1, 2) + (0, 0) == cirq.GridQubit(1, 2)
Expand Down Expand Up @@ -311,6 +312,7 @@ def test_addition_subtraction_numpy_array(dtype) -> None:


def test_unsupported_add() -> None:
# ruff: disable[RUF005]
with pytest.raises(TypeError, match='1'):
_ = cirq.GridQubit(1, 1) + 1 # type: ignore[operator]
with pytest.raises(TypeError, match='(1,)'):
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/devices/noise_properties_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ def test_noise_model_from_noise_properties_json() -> None:
q0, q1 = cirq.LineQubit.range(2)
props = SampleNoiseProperties([q0, q1], [(q0, q1), (q1, q0)])
model = NoiseModelFromNoiseProperties(props)
resolvers = [custom_resolver] + cirq.DEFAULT_RESOLVERS
resolvers = [custom_resolver, *cirq.DEFAULT_RESOLVERS]
cirq.testing.assert_json_roundtrip_works(model, resolvers=resolvers)
2 changes: 1 addition & 1 deletion cirq-core/cirq/interop/quirk/cells/swap_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def operations(self) -> cirq.OP_TREE:
return ops.SWAP(*self._qubits).controlled_by(*self._controls)

def controlled_by(self, qubit: cirq.Qid) -> SwapCell:
return SwapCell(self._qubits, self._controls + [qubit])
return SwapCell(self._qubits, [*self._controls, qubit])

def _value_equality_values_(self) -> Any:
return self._qubits, self._controls
Expand Down
3 changes: 2 additions & 1 deletion cirq-core/cirq/ops/classically_controlled_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ def _circuit_diagram_info_(
+ '(conditions=['
+ ', '.join(str(c) for c in self._conditions)
+ '])',
) + wire_symbols[1:]
*wire_symbols[1:],
)
exp_index = sub_info.exponent_qubit_index
if exp_index is None:
# None means at bottom, which means the last of the original wire symbols
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/common_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(
ValueError: if the args or the sum of args are not probabilities.
"""
if error_probabilities:
num_qubits = len(list(error_probabilities)[0])
num_qubits = len(next(iter(error_probabilities.keys())))
for k in error_probabilities.keys():
if not set(k).issubset({'I', 'X', 'Y', 'Z'}):
raise ValueError(f"{k} is not made solely of I, X, Y, Z.")
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/common_gate_families.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def __repr__(self) -> str:

def _value_equality_values_(self) -> Any:
# `isinstance` is used to ensure the a gate type and gate instance is not compared.
return super()._value_equality_values_() + (self._max_parallel_allowed,)
return (*super()._value_equality_values_(), self._max_parallel_allowed)

def _json_dict_(self):
return {
Expand Down
6 changes: 3 additions & 3 deletions cirq-core/cirq/ops/common_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ def controlled(
return ZPowGate(exponent=self.exponent).controlled(
num_controls=result.num_controls() + 1,
control_values=result.control_values & cv.ProductOfSums([1]),
control_qid_shape=result.control_qid_shape + (2,),
control_qid_shape=(*result.control_qid_shape, 2),
)

def _decompose_with_context_(
Expand Down Expand Up @@ -1339,7 +1339,7 @@ def controlled(
return XPowGate(exponent=self.exponent).controlled(
num_controls=result.num_controls() + 1,
control_values=result.control_values & cv.ProductOfSums([1]),
control_qid_shape=result.control_qid_shape + (2,),
control_qid_shape=(*result.control_qid_shape, 2),
)

def _qasm_(self, args: cirq.QasmArgs, qubits: tuple[cirq.Qid, ...]) -> str | None:
Expand Down Expand Up @@ -1498,7 +1498,7 @@ def controlled(
return YPowGate(exponent=self.exponent).controlled(
num_controls=result.num_controls() + 1,
control_values=result.control_values & cv.ProductOfSums([1]),
control_qid_shape=result.control_qid_shape + (2,),
control_qid_shape=(*result.control_qid_shape, 2),
)

def _qasm_(self, args: cirq.QasmArgs, qubits: tuple[cirq.Qid, ...]) -> str | None:
Expand Down
8 changes: 4 additions & 4 deletions cirq-core/cirq/ops/common_gates_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,18 @@ def test_specialized_control(input_gate, specialized_output, base_gate) -> None:
absorbed_values = ((1,),) * absorbed
absorbed_shape = (2,) * absorbed
assert input_gate.controlled(num_controls=1, control_qid_shape=(3,)) == cirq.ControlledGate(
base_gate, num_controls=1 + absorbed, control_qid_shape=(3,) + absorbed_shape
base_gate, num_controls=1 + absorbed, control_qid_shape=(3, *absorbed_shape)
)
assert input_gate.controlled(control_values=((0,), (1,), (0,))) == cirq.ControlledGate(
base_gate, num_controls=3 + absorbed, control_values=((0,), (1,), (0,)) + absorbed_values
base_gate, num_controls=3 + absorbed, control_values=((0,), (1,), (0,), *absorbed_values)
)
assert input_gate.controlled(control_qid_shape=(3, 2, 3)) == cirq.ControlledGate(
base_gate, num_controls=3 + absorbed, control_qid_shape=(3, 2, 3) + absorbed_shape
base_gate, num_controls=3 + absorbed, control_qid_shape=(3, 2, 3, *absorbed_shape)
)
assert input_gate.controlled(control_qid_shape=(3,)).controlled(
control_qid_shape=(2,)
).controlled(control_qid_shape=(4,)) != cirq.ControlledGate(
base_gate, num_controls=3 + absorbed, control_qid_shape=(3, 2, 4) + absorbed_shape
base_gate, num_controls=3 + absorbed, control_qid_shape=(3, 2, 4, *absorbed_shape)
)


Expand Down
4 changes: 2 additions & 2 deletions cirq-core/cirq/ops/diagonal_gate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ def test_unitary(n) -> None:
@pytest.mark.parametrize('resolve_fn', [cirq.resolve_parameters, cirq.resolve_parameters_once])
def test_resolve(resolve_fn) -> None:
diagonal_angles = [2, 3, 5, 7, 11, 13, 17, 19]
diagonal_gate = cirq.DiagonalGate(diagonal_angles[:6] + [sympy.Symbol('a'), sympy.Symbol('b')])
diagonal_gate = cirq.DiagonalGate([*diagonal_angles[:6], sympy.Symbol('a'), sympy.Symbol('b')])
assert cirq.is_parameterized(diagonal_gate)

diagonal_gate = resolve_fn(diagonal_gate, {'a': 17})
assert diagonal_gate == cirq.DiagonalGate(diagonal_angles[:7] + [sympy.Symbol('b')])
assert diagonal_gate == cirq.DiagonalGate([*diagonal_angles[:7], sympy.Symbol('b')])
assert cirq.is_parameterized(diagonal_gate)

diagonal_gate = resolve_fn(diagonal_gate, {'b': 19})
Expand Down
4 changes: 2 additions & 2 deletions cirq-core/cirq/ops/fourier_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def __repr__(self) -> str:

def _circuit_diagram_info_(self, args: cirq.CircuitDiagramInfoArgs) -> cirq.CircuitDiagramInfo:
return cirq.CircuitDiagramInfo(
wire_symbols=(str(self),) + tuple(f'#{k+1}' for k in range(1, self._num_qubits)),
wire_symbols=(str(self), *(f'#{k+1}' for k in range(1, self._num_qubits))),
exponent_qubit_index=0,
)

Expand Down Expand Up @@ -185,7 +185,7 @@ def __repr__(self) -> str:

def _circuit_diagram_info_(self, args: cirq.CircuitDiagramInfoArgs) -> cirq.CircuitDiagramInfo:
return cirq.CircuitDiagramInfo(
wire_symbols=('Grad',) + tuple(f'#{k+1}' for k in range(1, self._num_qubits)),
wire_symbols=('Grad', *(f'#{k+1}' for k in range(1, self._num_qubits))),
exponent=self.exponent,
exponent_qubit_index=0,
)
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/op_tree_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_flatten_to_ops_or_moments() -> None:
for i in range(10)
]
op_tree: cirq.OP_TREE = [operations[0], cirq.Moment(operations[1:5]), operations[5:]]
output = [operations[0], cirq.Moment(operations[1:5])] + operations[5:]
output = [operations[0], cirq.Moment(operations[1:5]), *operations[5:]]
assert list(cirq.flatten_to_ops_or_moments(op_tree)) == output
assert list(cirq.flatten_op_tree(op_tree, preserve_moments=True)) == output

Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/pauli_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def coefficient(self) -> cirq.TParamValComplex:

def _value_equality_values_(self):
if len(self._qubit_pauli_map) == 1 and self.coefficient == 1:
q, p = list(self._qubit_pauli_map.items())[0]
q, p = next(iter(self._qubit_pauli_map.items()))
return gate_operation.GateOperation(p, [q])._value_equality_values_()

return (frozenset(self._qubit_pauli_map.items()), self._coefficient)
Expand Down
3 changes: 2 additions & 1 deletion cirq-core/cirq/ops/raw_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,8 @@ def _circuit_diagram_info_(self, args: cirq.CircuitDiagramInfoArgs) -> cirq.Circ
if visible_tags:
sub_op_info.wire_symbols = (
sub_op_info.wire_symbols[0] + f"[{', '.join(map(str, visible_tags))}]",
) + sub_op_info.wire_symbols[1:]
*sub_op_info.wire_symbols[1:],
)
return sub_op_info

@cached_method
Expand Down
6 changes: 4 additions & 2 deletions cirq-core/cirq/ops/three_qubit_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ def _decompose_(self, qubits):
sweep_abc = [common_gates.CNOT(a, b), common_gates.CNOT(b, c)]
global_phase_gate = global_phase_op.from_phase_and_exponent(self.global_shift, exp)
global_phase_operation = [] if global_phase_gate.is_identity() else [global_phase_gate()]
return global_phase_operation + [
return [
*global_phase_operation,
p(a),
p(b),
p(c),
Expand Down Expand Up @@ -324,7 +325,8 @@ def _decompose_(self, qubits):
if protocols.is_parameterized(global_phase) or abs(global_phase - 1.0) > 0
else []
)
return global_phase_operation + [
return [
*global_phase_operation,
p_gates[0](a),
p_gates[1](b),
p_gates[2](c),
Expand Down
4 changes: 2 additions & 2 deletions cirq-core/cirq/ops/three_qubit_gates_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,12 @@ def test_diagonal_exponent() -> None:
def test_resolve(resolve_fn) -> None:
diagonal_angles = [2, 3, 5, 7, 11, 13, 17, 19]
diagonal_gate = cirq.ThreeQubitDiagonalGate(
diagonal_angles[:6] + [sympy.Symbol('a'), sympy.Symbol('b')]
[*diagonal_angles[:6], sympy.Symbol('a'), sympy.Symbol('b')]
)
assert cirq.is_parameterized(diagonal_gate)

diagonal_gate = resolve_fn(diagonal_gate, {'a': 17})
assert diagonal_gate == cirq.ThreeQubitDiagonalGate(diagonal_angles[:7] + [sympy.Symbol('b')])
assert diagonal_gate == cirq.ThreeQubitDiagonalGate([*diagonal_angles[:7], sympy.Symbol('b')])
assert cirq.is_parameterized(diagonal_gate)

diagonal_gate = resolve_fn(diagonal_gate, {'b': 19})
Expand Down
4 changes: 2 additions & 2 deletions cirq-core/cirq/ops/two_qubit_diagonal_gate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ def test_protocols_mul_not_implemented() -> None:
def test_resolve(resolve_fn) -> None:
diagonal_angles = [2, 3, 5, 7]
diagonal_gate = cirq.TwoQubitDiagonalGate(
diagonal_angles[:2] + [sympy.Symbol('a'), sympy.Symbol('b')]
[*diagonal_angles[:2], sympy.Symbol('a'), sympy.Symbol('b')]
)
assert cirq.is_parameterized(diagonal_gate)

diagonal_gate = resolve_fn(diagonal_gate, {'a': 5})
assert diagonal_gate == cirq.TwoQubitDiagonalGate(diagonal_angles[:3] + [sympy.Symbol('b')])
assert diagonal_gate == cirq.TwoQubitDiagonalGate([*diagonal_angles[:3], sympy.Symbol('b')])
assert cirq.is_parameterized(diagonal_gate)

diagonal_gate = resolve_fn(diagonal_gate, {'b': 7})
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/protocols/apply_channel_protocol_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def apply_channel(val, rho, left_axes, right_axes, assert_result_is_out_buf=Fals


def test_apply_channel_bad_args() -> None:
target = np.zeros((3,) + (1, 2, 3) + (3, 1, 2) + (3,))
target = np.zeros((3,) + (1, 2, 3) + (3, 1, 2) + (3,)) # noqa: RUF005
with pytest.raises(ValueError, match='Invalid target_tensor shape'):
cirq.apply_channel(
cirq.IdentityGate(3, (1, 2, 3)),
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/protocols/apply_mixture_protocol_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def assert_apply_mixture_returns(


def test_apply_mixture_bad_args() -> None:
target = np.zeros((3,) + (1, 2, 3) + (3, 1, 2) + (3,))
target = np.zeros((3,) + (1, 2, 3) + (3, 1, 2) + (3,)) # noqa: RUF005
with pytest.raises(ValueError, match='Invalid target_tensor shape'):
cirq.apply_mixture(
cirq.IdentityGate(3, (1, 2, 3)),
Expand Down
Loading
Loading