Skip to content

Commit 43d0372

Browse files
authored
Use f-strings in the pr_monitor tool (#6208)
* pr_monitor - convert to f-strings to satisfy pylint consider-using-f-string * clean up some redundant fixed strings concatenations * also pin pytest-cov==3 to unblock CI coverage check which failed because pytest-cov==4.1.0 does not see line hits in a subprocess. Finalizes #6171
1 parent 6e562e6 commit 43d0372

File tree

9 files changed

+65
-92
lines changed

9 files changed

+65
-92
lines changed

cirq-core/cirq/_compat_test.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,7 @@ def test_deprecated_module_deadline_validation():
781781

782782
def _test_broken_module_1_inner():
783783
with pytest.raises(
784-
DeprecatedModuleImportError,
785-
match="missing_module cannot be imported. " "The typical reasons",
784+
DeprecatedModuleImportError, match="missing_module cannot be imported. The typical reasons"
786785
):
787786
# pylint: disable=unused-import
788787
import cirq.testing._compat_test_data.broken_ref as br # type: ignore

cirq-core/cirq/qis/measures.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def _numpy_arrays_to_state_vectors_or_density_matrices(
211211
state2.shape[0] if state2.ndim == 2 else np.prod(state2.shape, dtype=np.int64).item()
212212
)
213213
if dim1 != dim2:
214-
raise ValueError('Mismatched dimensions in given states: ' f'{dim1} and {dim2}.')
214+
raise ValueError(f'Mismatched dimensions in given states: {dim1} and {dim2}.')
215215
if qid_shape is None:
216216
qid_shape = (dim1,)
217217
else:

cirq-core/cirq/qis/states.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def density_matrix(
314314
ValueError: Invalid density matrix.
315315
"""
316316
if state.ndim != 2 or state.shape[0] != state.shape[1]:
317-
raise ValueError('A density matrix must be a square matrix. ' f'Got shape {state.shape}.')
317+
raise ValueError(f'A density matrix must be a square matrix. Got shape {state.shape}.')
318318
dim, _ = state.shape
319319
if qid_shape is None:
320320
qid_shape = _infer_qid_shape_from_dimension(dim)

cirq-google/cirq_google/calibration/engine_simulator.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ def _convert_to_circuit_with_drift(
482482
simulator: PhasedFSimEngineSimulator, circuit: cirq.AbstractCircuit
483483
) -> cirq.Circuit:
484484
def map_func(op: cirq.Operation, _) -> cirq.Operation:
485-
486485
if op.gate is None:
487486
raise IncompatibleMomentError(f'Operation {op} has a missing gate')
488487

@@ -495,7 +494,7 @@ def map_func(op: cirq.Operation, _) -> cirq.Operation:
495494
translated = simulator.gates_translator(op.gate)
496495
if translated is None:
497496
raise IncompatibleMomentError(
498-
f'Moment contains non-single qubit operation ' f'{op} with unsupported gate'
497+
f'Moment contains non-single qubit operation {op} with unsupported gate'
499498
)
500499

501500
a, b = op.qubits

cirq-google/cirq_google/engine/engine_program.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ def _deserialize_program(code: any_pb2.Any, program_num: Optional[int] = None) -
550550
batch = v2.batch_pb2.BatchProgram.FromString(code.value)
551551
if abs(program_num) >= len(batch.programs):
552552
raise ValueError(
553-
f'Only {len(batch.programs)} in the batch but ' f'index {program_num} was specified'
553+
f'Only {len(batch.programs)} in the batch but index {program_num} was specified'
554554
)
555555

556556
program = batch.programs[program_num]

cirq-google/cirq_google/serialization/op_serializer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def to_proto(
134134
except KeyError as err:
135135
# Circuits must be serialized prior to any CircuitOperations that use them.
136136
raise ValueError(
137-
'Encountered a circuit not in the constants table. ' f'Full error message:\n{err}'
137+
f'Encountered a circuit not in the constants table. Full error message:\n{err}'
138138
)
139139

140140
if (

dev_tools/modules.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def _print_version():
220220

221221
def _add_print_version_cmd(subparsers):
222222
print_version_cmd = subparsers.add_parser(
223-
"print_version", help="Check that all module versions are the same, " "and print it."
223+
"print_version", help="Check that all module versions are the same, and print it."
224224
)
225225
print_version_cmd.set_defaults(func=_print_version)
226226

0 commit comments

Comments
 (0)