Skip to content

Commit f61a536

Browse files
pavoljuhasrht
authored andcommitted
Fix lint in pylintrc (quantumlib#5952)
* Add missing comma after f-string-without-interpolation Remove obsolete checks `mixed-indentation` and `relative-import` specific to Python 2. Resolve pylint 2.15 complaints about these. * Clean redundant f-strings that show for fixed pylintrc
1 parent 4b9b9da commit f61a536

File tree

8 files changed

+23
-25
lines changed

8 files changed

+23
-25
lines changed

cirq-core/cirq/circuits/circuit_operation_test.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ def test_string_format():
541541

542542
fc0 = cirq.FrozenCircuit()
543543
op0 = cirq.CircuitOperation(fc0)
544-
assert str(op0) == f"[ ]"
544+
assert str(op0) == "[ ]"
545545

546546
fc0_global_phase_inner = cirq.FrozenCircuit(
547547
cirq.global_phase_operation(1j), cirq.global_phase_operation(1j)
@@ -553,7 +553,7 @@ def test_string_format():
553553
op0_global_phase_outer = cirq.CircuitOperation(fc0_global_phase_outer)
554554
assert (
555555
str(op0_global_phase_outer)
556-
== f"""\
556+
== """\
557557
[ ]
558558
[ ]
559559
[ global phase: -0.5π ]"""
@@ -563,7 +563,7 @@ def test_string_format():
563563
op1 = cirq.CircuitOperation(fc1)
564564
assert (
565565
str(op1)
566-
== f"""\
566+
== """\
567567
[ 0: ───X───────M('m')─── ]
568568
[ │ ]
569569
[ 1: ───H───@───M──────── ]
@@ -599,10 +599,10 @@ def test_string_format():
599599
)
600600
assert (
601601
str(op2)
602-
== f"""\
602+
== """\
603603
[ 0: ───X───X─── ]
604604
[ │ ]
605-
[ 1: ───H───@─── ](qubit_map={{q(1): q(2)}}, parent_path=('outer', 'inner'),\
605+
[ 1: ───H───@─── ](qubit_map={q(1): q(2)}, parent_path=('outer', 'inner'),\
606606
repetition_ids=['a', 'b', 'c'])"""
607607
)
608608
assert (
@@ -635,9 +635,9 @@ def test_string_format():
635635
indented_fc3_repr = repr(fc3).replace('\n', '\n ')
636636
assert (
637637
str(op3)
638-
== f"""\
639-
[ 0: ───X^b───M('m')─── ](qubit_map={{q(0): q(1)}}, \
640-
key_map={{m: p}}, params={{b: 2}})"""
638+
== """\
639+
[ 0: ───X^b───M('m')─── ](qubit_map={q(0): q(1)}, \
640+
key_map={m: p}, params={b: 2})"""
641641
)
642642
assert (
643643
repr(op3)

cirq-core/cirq/experiments/readout_confusion_matrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def __init__(
8585
pattern.
8686
"""
8787
if len(measure_qubits) == 0:
88-
raise ValueError(f"measure_qubits cannot be empty.")
88+
raise ValueError("measure_qubits cannot be empty.")
8989
if isinstance(confusion_matrices, np.ndarray):
9090
confusion_matrices = [confusion_matrices]
9191
measure_qubits = cast(

cirq-core/cirq/qis/clifford_tableau.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,9 @@ def _reconstruct_rs(self, rs: Optional[np.ndarray]) -> np.ndarray:
174174
new_rs = np.append(rs, np.zeros(1, dtype=bool))
175175
else:
176176
raise ValueError(
177-
f"The value you passed for rs is not the correct shape and/or type. "
178-
f"Please confirm that it's a single row with 2*num_qubits columns "
179-
f"and of type bool."
177+
"The value you passed for rs is not the correct shape and/or type. "
178+
"Please confirm that it's a single row with 2*num_qubits columns "
179+
"and of type bool."
180180
)
181181
return new_rs
182182

@@ -196,9 +196,9 @@ def _reconstruct_xs(self, xs: Optional[np.ndarray]) -> np.ndarray:
196196
new_xs = np.append(xs, np.zeros((1, self.n), dtype=bool), axis=0)
197197
else:
198198
raise ValueError(
199-
f"The value you passed for xs is not the correct shape and/or type. "
200-
f"Please confirm that it's 2*num_qubits rows, num_qubits columns, "
201-
f"and of type bool."
199+
"The value you passed for xs is not the correct shape and/or type. "
200+
"Please confirm that it's 2*num_qubits rows, num_qubits columns, "
201+
"and of type bool."
202202
)
203203
return new_xs
204204

@@ -219,9 +219,9 @@ def _reconstruct_zs(self, zs: Optional[np.ndarray]) -> np.ndarray:
219219
new_zs = np.append(zs, np.zeros((1, self.n), dtype=bool), axis=0)
220220
else:
221221
raise ValueError(
222-
f"The value you passed for zs is not the correct shape and/or type. "
223-
f"Please confirm that it's 2*num_qubits rows, num_qubits columns, "
224-
f"and of type bool."
222+
"The value you passed for zs is not the correct shape and/or type. "
223+
"Please confirm that it's 2*num_qubits rows, num_qubits columns, "
224+
"and of type bool."
225225
)
226226
return new_zs
227227

cirq-core/cirq/testing/circuit_compare.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def assert_circuits_have_same_unitary_given_final_permutation(
241241

242242
if not set(qubit_map.keys()).issubset(actual.all_qubits()):
243243
raise ValueError(
244-
f"'qubit_map' must be a mapping of the qubits in the circuit 'actual' to themselves."
244+
"'qubit_map' must be a mapping of the qubits in the circuit 'actual' to themselves."
245245
)
246246

247247
actual_cp = actual.unfreeze()

cirq-core/cirq/testing/routing_devices_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_allowed_multi_qubit_gates():
9999
device.validate_operation(cirq.MeasurementGate(2).on(*cirq.LineQubit.range(2)))
100100
device.validate_operation(cirq.MeasurementGate(3).on(*cirq.LineQubit.range(3)))
101101

102-
with pytest.raises(ValueError, match=f"Unsupported operation"):
102+
with pytest.raises(ValueError, match="Unsupported operation"):
103103
device.validate_operation(cirq.CCNOT(*cirq.LineQubit.range(3)))
104104

105105
device.validate_operation(cirq.CNOT(*cirq.LineQubit.range(2)))

cirq-google/cirq_google/engine/engine_validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def _verify_reps(
5151
total_reps += len(list(cirq.to_resolvers(sweep))) * repetitions
5252
if total_reps > max_repetitions:
5353
raise RuntimeError(
54-
f'No requested processors currently support the number of requested total repetitions.'
54+
'No requested processors currently support the number of requested total repetitions.'
5555
)
5656

5757

cirq-google/cirq_google/engine/qcs_notebook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def get_qcs_objects_for_notebook(
106106
print("Authentication complete.")
107107
except Exception as exc:
108108
print(f"Authentication failed: {exc}")
109-
print(f"Using virtual engine instead.")
109+
print("Using virtual engine instead.")
110110
virtual = True
111111

112112
if not virtual:

dev_tools/conf/.pylintrc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ enable=
2020
docstyle,
2121
duplicate-argument-name,
2222
expression-not-assigned,
23-
f-string-without-interpolation
23+
f-string-without-interpolation,
2424
function-redefined,
2525
inconsistent-mro,
2626
init-is-generator,
@@ -29,14 +29,12 @@ enable=
2929
missing-kwoa,
3030
missing-param-doc,
3131
missing-raises-doc,
32-
mixed-indentation,
3332
mixed-line-endings,
3433
no-value-for-parameter,
3534
nonexistent-operator,
3635
not-in-loop,
3736
pointless-statement,
3837
redefined-builtin,
39-
relative-import,
4038
return-arg-in-generator,
4139
return-in-init,
4240
return-outside-function,

0 commit comments

Comments
 (0)