Skip to content

Commit

Permalink
Fix lint in pylintrc (quantumlib#5952)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
pavoljuhas authored and rht committed May 1, 2023
1 parent 4b9b9da commit f61a536
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 25 deletions.
16 changes: 8 additions & 8 deletions cirq-core/cirq/circuits/circuit_operation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def test_string_format():

fc0 = cirq.FrozenCircuit()
op0 = cirq.CircuitOperation(fc0)
assert str(op0) == f"[ ]"
assert str(op0) == "[ ]"

fc0_global_phase_inner = cirq.FrozenCircuit(
cirq.global_phase_operation(1j), cirq.global_phase_operation(1j)
Expand All @@ -553,7 +553,7 @@ def test_string_format():
op0_global_phase_outer = cirq.CircuitOperation(fc0_global_phase_outer)
assert (
str(op0_global_phase_outer)
== f"""\
== """\
[ ]
[ ]
[ global phase: -0.5π ]"""
Expand All @@ -563,7 +563,7 @@ def test_string_format():
op1 = cirq.CircuitOperation(fc1)
assert (
str(op1)
== f"""\
== """\
[ 0: ───X───────M('m')─── ]
[ │ ]
[ 1: ───H───@───M──────── ]
Expand Down Expand Up @@ -599,10 +599,10 @@ def test_string_format():
)
assert (
str(op2)
== f"""\
== """\
[ 0: ───X───X─── ]
[ │ ]
[ 1: ───H───@─── ](qubit_map={{q(1): q(2)}}, parent_path=('outer', 'inner'),\
[ 1: ───H───@─── ](qubit_map={q(1): q(2)}, parent_path=('outer', 'inner'),\
repetition_ids=['a', 'b', 'c'])"""
)
assert (
Expand Down Expand Up @@ -635,9 +635,9 @@ def test_string_format():
indented_fc3_repr = repr(fc3).replace('\n', '\n ')
assert (
str(op3)
== f"""\
[ 0: ───X^b───M('m')─── ](qubit_map={{q(0): q(1)}}, \
key_map={{m: p}}, params={{b: 2}})"""
== """\
[ 0: ───X^b───M('m')─── ](qubit_map={q(0): q(1)}, \
key_map={m: p}, params={b: 2})"""
)
assert (
repr(op3)
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/experiments/readout_confusion_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(
pattern.
"""
if len(measure_qubits) == 0:
raise ValueError(f"measure_qubits cannot be empty.")
raise ValueError("measure_qubits cannot be empty.")
if isinstance(confusion_matrices, np.ndarray):
confusion_matrices = [confusion_matrices]
measure_qubits = cast(
Expand Down
18 changes: 9 additions & 9 deletions cirq-core/cirq/qis/clifford_tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ def _reconstruct_rs(self, rs: Optional[np.ndarray]) -> np.ndarray:
new_rs = np.append(rs, np.zeros(1, dtype=bool))
else:
raise ValueError(
f"The value you passed for rs is not the correct shape and/or type. "
f"Please confirm that it's a single row with 2*num_qubits columns "
f"and of type bool."
"The value you passed for rs is not the correct shape and/or type. "
"Please confirm that it's a single row with 2*num_qubits columns "
"and of type bool."
)
return new_rs

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

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

Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/testing/circuit_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def assert_circuits_have_same_unitary_given_final_permutation(

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

actual_cp = actual.unfreeze()
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/testing/routing_devices_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_allowed_multi_qubit_gates():
device.validate_operation(cirq.MeasurementGate(2).on(*cirq.LineQubit.range(2)))
device.validate_operation(cirq.MeasurementGate(3).on(*cirq.LineQubit.range(3)))

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

device.validate_operation(cirq.CNOT(*cirq.LineQubit.range(2)))
Expand Down
2 changes: 1 addition & 1 deletion cirq-google/cirq_google/engine/engine_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _verify_reps(
total_reps += len(list(cirq.to_resolvers(sweep))) * repetitions
if total_reps > max_repetitions:
raise RuntimeError(
f'No requested processors currently support the number of requested total repetitions.'
'No requested processors currently support the number of requested total repetitions.'
)


Expand Down
2 changes: 1 addition & 1 deletion cirq-google/cirq_google/engine/qcs_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def get_qcs_objects_for_notebook(
print("Authentication complete.")
except Exception as exc:
print(f"Authentication failed: {exc}")
print(f"Using virtual engine instead.")
print("Using virtual engine instead.")
virtual = True

if not virtual:
Expand Down
4 changes: 1 addition & 3 deletions dev_tools/conf/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ enable=
docstyle,
duplicate-argument-name,
expression-not-assigned,
f-string-without-interpolation
f-string-without-interpolation,
function-redefined,
inconsistent-mro,
init-is-generator,
Expand All @@ -29,14 +29,12 @@ enable=
missing-kwoa,
missing-param-doc,
missing-raises-doc,
mixed-indentation,
mixed-line-endings,
no-value-for-parameter,
nonexistent-operator,
not-in-loop,
pointless-statement,
redefined-builtin,
relative-import,
return-arg-in-generator,
return-in-init,
return-outside-function,
Expand Down

0 comments on commit f61a536

Please sign in to comment.