From 8e70f775f4f4f5a4658027d8a7124d308aa3bd3c Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Wed, 12 Jul 2023 16:30:31 -0700 Subject: [PATCH] Remove dependency on the flynt tool (#6164) - pylint - enable `consider-using-f-string` check - Test package metadata with numpy rather than flynt - Fix CI complains on test coverage - fix markup for ignoring coverage - Temporarily disable consider-using-f-string pylint and add TODO-s to fix later - Format touched files with black-23.3.0 Partially fixes #6171 --------- Co-authored-by: Tanuj Khattar --- cirq-core/cirq/_compat_test.py | 16 +++------ .../circuits/_block_diagram_drawer_test.py | 4 +++ cirq-core/cirq/circuits/circuit_operation.py | 4 +++ .../cirq/circuits/text_diagram_drawer_test.py | 3 ++ .../cirq/contrib/acquaintance/bipartite.py | 3 ++ .../cirq/contrib/acquaintance/devices.py | 3 ++ cirq-core/cirq/contrib/acquaintance/gates.py | 3 ++ .../cirq/contrib/acquaintance/testing.py | 3 ++ .../cirq/contrib/paulistring/recombine.py | 5 +-- cirq-core/cirq/contrib/qasm_import/_parser.py | 4 +++ .../cirq/contrib/qasm_import/_parser_test.py | 4 +++ .../cirq/contrib/qcircuit/qcircuit_test.py | 3 ++ cirq-core/cirq/contrib/quirk/quirk_gate.py | 3 ++ cirq-core/cirq/devices/noise_model.py | 3 ++ cirq-core/cirq/linalg/diagonalize_test.py | 3 ++ cirq-core/cirq/linalg/transformations.py | 3 ++ cirq-core/cirq/ops/clifford_gate.py | 4 ++- cirq-core/cirq/ops/common_gate_families.py | 3 ++ cirq-core/cirq/ops/common_gates.py | 4 +++ cirq-core/cirq/ops/diagonal_gate.py | 3 ++ cirq-core/cirq/ops/gateset_test.py | 3 ++ cirq-core/cirq/ops/linear_combinations.py | 4 +++ cirq-core/cirq/ops/raw_types.py | 3 ++ cirq-core/cirq/ops/three_qubit_gates.py | 3 ++ cirq-core/cirq/ops/two_qubit_diagonal_gate.py | 4 +++ .../cirq/protocols/apply_channel_protocol.py | 4 +++ .../cirq/protocols/apply_mixture_protocol.py | 4 +++ .../cirq/protocols/apply_unitary_protocol.py | 5 +++ .../circuit_diagram_info_protocol.py | 5 ++- cirq-core/cirq/protocols/inverse_protocol.py | 3 ++ cirq-core/cirq/protocols/kraus_protocol.py | 3 ++ cirq-core/cirq/protocols/mixture_protocol.py | 4 +++ cirq-core/cirq/protocols/phase_protocol.py | 3 ++ cirq-core/cirq/protocols/pow_protocol.py | 3 ++ cirq-core/cirq/protocols/qasm.py | 3 ++ .../cirq/protocols/qid_shape_protocol.py | 3 ++ cirq-core/cirq/protocols/unitary_protocol.py | 3 ++ cirq-core/cirq/qis/clifford_tableau.py | 6 ++-- cirq-core/cirq/qis/states.py | 4 +++ .../cirq/sim/clifford/clifford_simulator.py | 5 ++- .../sim/density_matrix_simulation_state.py | 4 +++ cirq-core/cirq/sim/density_matrix_utils.py | 4 +++ cirq-core/cirq/sim/mux.py | 3 ++ cirq-core/cirq/sim/simulator.py | 3 ++ .../cirq/sim/state_vector_simulation_state.py | 4 +++ cirq-core/cirq/testing/circuit_compare.py | 4 +++ cirq-core/cirq/testing/consistent_act_on.py | 3 ++ .../cirq/testing/consistent_protocols_test.py | 3 ++ cirq-core/cirq/testing/consistent_qasm.py | 4 +++ .../consistent_specified_has_unitary.py | 3 ++ .../cirq/testing/equivalent_repr_eval.py | 3 ++ cirq-core/cirq/testing/order_tester.py | 3 ++ .../three_qubit_decomposition_test.py | 3 ++ cirq-core/cirq/value/abc_alt.py | 4 +++ cirq-core/cirq/value/digits.py | 3 ++ cirq-core/cirq/value/linear_dict.py | 3 ++ cirq-core/cirq/value/product_state.py | 4 +++ cirq-core/cirq/work/observable_settings.py | 3 ++ cirq-google/cirq_google/api/v1/programs.py | 4 +++ .../services/quantum_engine_service/client.py | 18 +++++----- .../services/quantum_engine_service/pagers.py | 36 +++++++++---------- cirq-google/cirq_google/engine/calibration.py | 4 +++ .../cirq_google/engine/engine_processor.py | 4 +++ .../serialization/circuit_serializer.py | 4 +++ cirq-pasqal/cirq_pasqal/pasqal_device.py | 4 +++ dev_tools/bash_scripts_test.py | 6 ++-- dev_tools/conf/.pylintrc | 1 + dev_tools/incremental_coverage.py | 3 ++ dev_tools/pr_monitor.py | 4 +++ dev_tools/prepared_env.py | 3 ++ dev_tools/profiling/benchmark_simulators.py | 3 ++ dev_tools/snippets_test.py | 4 +++ examples/bernstein_vazirani.py | 4 +++ examples/swap_networks.py | 4 +++ 74 files changed, 275 insertions(+), 48 deletions(-) diff --git a/cirq-core/cirq/_compat_test.py b/cirq-core/cirq/_compat_test.py index 7ea28d053e9..39b4e297566 100644 --- a/cirq-core/cirq/_compat_test.py +++ b/cirq-core/cirq/_compat_test.py @@ -200,9 +200,8 @@ def old_func(*args, **kwargs): with pytest.raises(AssertionError, match='deadline should match vX.Y'): # pylint: disable=unused-variable - # coverage: ignore @deprecated(deadline='invalid', fix='Roll some dice.') - def badly_deprecated_func(*args, **kwargs): + def badly_deprecated_func(*args, **kwargs): # pragma: no cover return new_func(*args, **kwargs) # pylint: enable=unused-variable @@ -258,8 +257,7 @@ def f(new_count): rewrite=lambda args, kwargs: (args, {'new_count': kwargs['double_count'] * 2}), ) # pylint: disable=unused-variable - # coverage: ignore - def f_with_badly_deprecated_param(new_count): + def f_with_badly_deprecated_param(new_count): # pragma: no cover return new_count # pylint: enable=unused-variable @@ -371,9 +369,8 @@ class OldClass(NewClass): with pytest.raises(AssertionError, match='deadline should match vX.Y'): # pylint: disable=unused-variable - # coverage: ignore @deprecated_class(deadline='invalid', fix='theFix', name='foo') - class BadlyDeprecatedClass(NewClass): + class BadlyDeprecatedClass(NewClass): # pragma: no cover ... # pylint: enable=unused-variable @@ -619,8 +616,6 @@ def subprocess_context(test_func): "it to this method?" ) - import os - ctx = multiprocessing.get_context('spawn' if os.name == 'nt' else 'fork') exception = ctx.Queue() @@ -632,8 +627,7 @@ def isolated_func(*args, **kwargs): p.start() p.join() result = exception.get() - if result: - # coverage: ignore + if result: # pragma: no cover ex_type, msg, ex_trace = result if ex_type == "Skipped": warnings.warn(f"Skipping: {ex_type}: {msg}\n{ex_trace}") @@ -727,7 +721,7 @@ def _test_metadata_search_path_inner(): # pragma: no cover # pylint: disable=unused-import import cirq.testing._compat_test_data.module_a - assert importlib.metadata.metadata('flynt') + assert importlib.metadata.metadata('numpy') def test_metadata_distributions_after_deprecated_submodule(): diff --git a/cirq-core/cirq/circuits/_block_diagram_drawer_test.py b/cirq-core/cirq/circuits/_block_diagram_drawer_test.py index 43a38087afc..f219adaaa6f 100644 --- a/cirq-core/cirq/circuits/_block_diagram_drawer_test.py +++ b/cirq-core/cirq/circuits/_block_diagram_drawer_test.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + import itertools import pytest diff --git a/cirq-core/cirq/circuits/circuit_operation.py b/cirq-core/cirq/circuits/circuit_operation.py index fe8442414d2..2bf932c9413 100644 --- a/cirq-core/cirq/circuits/circuit_operation.py +++ b/cirq-core/cirq/circuits/circuit_operation.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """A structure for encapsulating entire circuits in an operation. A CircuitOperation is an Operation object that wraps a FrozenCircuit. When diff --git a/cirq-core/cirq/circuits/text_diagram_drawer_test.py b/cirq-core/cirq/circuits/text_diagram_drawer_test.py index b9f032d024a..78f0318c418 100644 --- a/cirq-core/cirq/circuits/text_diagram_drawer_test.py +++ b/cirq-core/cirq/circuits/text_diagram_drawer_test.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from unittest import mock import pytest diff --git a/cirq-core/cirq/contrib/acquaintance/bipartite.py b/cirq-core/cirq/contrib/acquaintance/bipartite.py index 5d30699fd55..8076039aa15 100644 --- a/cirq-core/cirq/contrib/acquaintance/bipartite.py +++ b/cirq-core/cirq/contrib/acquaintance/bipartite.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + import enum import itertools from typing import Dict, Sequence, Tuple, Union, TYPE_CHECKING diff --git a/cirq-core/cirq/contrib/acquaintance/devices.py b/cirq-core/cirq/contrib/acquaintance/devices.py index a2fc0c4d75a..1cc03e21b50 100644 --- a/cirq-core/cirq/contrib/acquaintance/devices.py +++ b/cirq-core/cirq/contrib/acquaintance/devices.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Union, TYPE_CHECKING import abc diff --git a/cirq-core/cirq/contrib/acquaintance/gates.py b/cirq-core/cirq/contrib/acquaintance/gates.py index 9678aeae545..2cc80234aa9 100644 --- a/cirq-core/cirq/contrib/acquaintance/gates.py +++ b/cirq-core/cirq/contrib/acquaintance/gates.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + import functools import itertools import math diff --git a/cirq-core/cirq/contrib/acquaintance/testing.py b/cirq-core/cirq/contrib/acquaintance/testing.py index faf95e57929..21f9b2dd1f2 100644 --- a/cirq-core/cirq/contrib/acquaintance/testing.py +++ b/cirq-core/cirq/contrib/acquaintance/testing.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import cast, Sequence, TYPE_CHECKING from cirq import devices, ops, protocols diff --git a/cirq-core/cirq/contrib/paulistring/recombine.py b/cirq-core/cirq/contrib/paulistring/recombine.py index 5780a8d8965..03d9eb5d5f3 100644 --- a/cirq-core/cirq/contrib/paulistring/recombine.py +++ b/cirq-core/cirq/contrib/paulistring/recombine.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Any, Callable, Iterable, Sequence, Tuple, Union, cast, List from cirq import circuits, ops, protocols @@ -27,7 +30,6 @@ def _sorted_best_string_placements( output_ops: Sequence[ops.Operation], key: Callable[[Any], ops.PauliStringPhasor] = lambda node: node.val, ) -> List[Tuple[ops.PauliStringPhasor, int, circuitdag.Unique[ops.PauliStringPhasor]]]: - sort_key = lambda placement: (-len(placement[0].pauli_string), placement[1]) node_maxes = [] @@ -84,7 +86,6 @@ def move_pauli_strings_into_circuit( # Pick the Pauli string that can be moved furthest through # the Clifford circuit for best_string_op, best_index, best_node in placements: - assert ( best_index <= last_index ), "Unexpected insertion index order, {} >= {}, len: {}".format( diff --git a/cirq-core/cirq/contrib/qasm_import/_parser.py b/cirq-core/cirq/contrib/qasm_import/_parser.py index 3e54558bc4a..005a6327152 100644 --- a/cirq-core/cirq/contrib/qasm_import/_parser.py +++ b/cirq-core/cirq/contrib/qasm_import/_parser.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + import functools import operator from typing import Any, Callable, cast, Dict, Iterable, List, Optional, Union, TYPE_CHECKING diff --git a/cirq-core/cirq/contrib/qasm_import/_parser_test.py b/cirq-core/cirq/contrib/qasm_import/_parser_test.py index 0818e43ddac..1c596ddde27 100644 --- a/cirq-core/cirq/contrib/qasm_import/_parser_test.py +++ b/cirq-core/cirq/contrib/qasm_import/_parser_test.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Callable import numpy as np diff --git a/cirq-core/cirq/contrib/qcircuit/qcircuit_test.py b/cirq-core/cirq/contrib/qcircuit/qcircuit_test.py index 0d8220bee28..7938e65df70 100644 --- a/cirq-core/cirq/contrib/qcircuit/qcircuit_test.py +++ b/cirq-core/cirq/contrib/qcircuit/qcircuit_test.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + import cirq import cirq.contrib.qcircuit as ccq import cirq.testing as ct diff --git a/cirq-core/cirq/contrib/quirk/quirk_gate.py b/cirq-core/cirq/contrib/quirk/quirk_gate.py index 32869194e1b..7c964167ff8 100644 --- a/cirq-core/cirq/contrib/quirk/quirk_gate.py +++ b/cirq-core/cirq/contrib/quirk/quirk_gate.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Any, Callable, cast, Dict, Optional, Union import numpy as np diff --git a/cirq-core/cirq/devices/noise_model.py b/cirq-core/cirq/devices/noise_model.py index 8395d9e1f1e..7126792bca5 100644 --- a/cirq-core/cirq/devices/noise_model.py +++ b/cirq-core/cirq/devices/noise_model.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Any, Dict, Iterable, Sequence, TYPE_CHECKING, Union, Callable from cirq import ops, protocols, value diff --git a/cirq-core/cirq/linalg/diagonalize_test.py b/cirq-core/cirq/linalg/diagonalize_test.py index 3b79da5f2d7..100fabb6470 100644 --- a/cirq-core/cirq/linalg/diagonalize_test.py +++ b/cirq-core/cirq/linalg/diagonalize_test.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + import random from typing import Tuple, Optional diff --git a/cirq-core/cirq/linalg/transformations.py b/cirq-core/cirq/linalg/transformations.py index ba02322c62f..54cd9be06c4 100644 --- a/cirq-core/cirq/linalg/transformations.py +++ b/cirq-core/cirq/linalg/transformations.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Utility methods for transforming matrices or vectors.""" import dataclasses diff --git a/cirq-core/cirq/ops/clifford_gate.py b/cirq-core/cirq/ops/clifford_gate.py index ab014808c7a..3495d97f666 100644 --- a/cirq-core/cirq/ops/clifford_gate.py +++ b/cirq-core/cirq/ops/clifford_gate.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Any, Dict, List, Optional, Sequence, Tuple, TYPE_CHECKING, Union @@ -434,7 +437,6 @@ def _decompose_(self, qubits: Sequence['cirq.Qid']) -> 'cirq.OP_TREE': def _act_on_( self, sim_state: 'cirq.SimulationStateBase', qubits: Sequence['cirq.Qid'] ) -> Union[NotImplementedType, bool]: - # Note the computation complexity difference between _decompose_ and _act_on_. # Suppose this Gate has `m` qubits, args has `n` qubits, and the decomposition of # this operation into `k` operations: diff --git a/cirq-core/cirq/ops/common_gate_families.py b/cirq-core/cirq/ops/common_gate_families.py index 96eb3fb95e3..77c4b90f8c8 100644 --- a/cirq-core/cirq/ops/common_gate_families.py +++ b/cirq-core/cirq/ops/common_gate_families.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Common Gate Families used in cirq-core""" from typing import Any, cast, Optional, Type, Union diff --git a/cirq-core/cirq/ops/common_gates.py b/cirq-core/cirq/ops/common_gates.py index 1d1359ec82c..815623ce683 100644 --- a/cirq-core/cirq/ops/common_gates.py +++ b/cirq-core/cirq/ops/common_gates.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Quantum gates that are commonly used in the literature. This module creates Gate instances for the following gates: diff --git a/cirq-core/cirq/ops/diagonal_gate.py b/cirq-core/cirq/ops/diagonal_gate.py index c514b92f099..d412e8baedc 100644 --- a/cirq-core/cirq/ops/diagonal_gate.py +++ b/cirq-core/cirq/ops/diagonal_gate.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Creates the gate instance for any number qubits diagonal gate. The gate is used to create a (2^n)x(2^n) matrix with the diagonal elements diff --git a/cirq-core/cirq/ops/gateset_test.py b/cirq-core/cirq/ops/gateset_test.py index c7adc18c8b5..0e24e63ec48 100644 --- a/cirq-core/cirq/ops/gateset_test.py +++ b/cirq-core/cirq/ops/gateset_test.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Tuple, List, cast import re import pytest diff --git a/cirq-core/cirq/ops/linear_combinations.py b/cirq-core/cirq/ops/linear_combinations.py index 469f3c6555d..1c9f82cd9d3 100644 --- a/cirq-core/cirq/ops/linear_combinations.py +++ b/cirq-core/cirq/ops/linear_combinations.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from collections import defaultdict from typing import ( AbstractSet, diff --git a/cirq-core/cirq/ops/raw_types.py b/cirq-core/cirq/ops/raw_types.py index b38b0c6bd66..e5fd9825fbc 100644 --- a/cirq-core/cirq/ops/raw_types.py +++ b/cirq-core/cirq/ops/raw_types.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Basic types defining qubits, gates, and operations.""" import abc diff --git a/cirq-core/cirq/ops/three_qubit_gates.py b/cirq-core/cirq/ops/three_qubit_gates.py index 2851a9dd8ed..635ace70139 100644 --- a/cirq-core/cirq/ops/three_qubit_gates.py +++ b/cirq-core/cirq/ops/three_qubit_gates.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Common quantum gates that target three qubits.""" from typing import ( diff --git a/cirq-core/cirq/ops/two_qubit_diagonal_gate.py b/cirq-core/cirq/ops/two_qubit_diagonal_gate.py index 3f8042f296c..84f7f169dcd 100644 --- a/cirq-core/cirq/ops/two_qubit_diagonal_gate.py +++ b/cirq-core/cirq/ops/two_qubit_diagonal_gate.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Creates the gate instance for a two qubit diagonal gate. The gate is used to create a 4x4 matrix with the diagonal elements diff --git a/cirq-core/cirq/protocols/apply_channel_protocol.py b/cirq-core/cirq/protocols/apply_channel_protocol.py index ca52651003f..9211f89828c 100644 --- a/cirq-core/cirq/protocols/apply_channel_protocol.py +++ b/cirq-core/cirq/protocols/apply_channel_protocol.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """A protocol for implementing high performance channel evolutions.""" from typing import Any, Iterable, Optional, Sequence, TypeVar, Tuple, Union diff --git a/cirq-core/cirq/protocols/apply_mixture_protocol.py b/cirq-core/cirq/protocols/apply_mixture_protocol.py index 853d2be008f..e7787b2a481 100644 --- a/cirq-core/cirq/protocols/apply_mixture_protocol.py +++ b/cirq-core/cirq/protocols/apply_mixture_protocol.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """A protocol for implementing high performance mixture evolutions.""" from typing import Any, cast, Iterable, Optional, Tuple, TypeVar, Union diff --git a/cirq-core/cirq/protocols/apply_unitary_protocol.py b/cirq-core/cirq/protocols/apply_unitary_protocol.py index e3dc092dca1..58293cbf3f7 100644 --- a/cirq-core/cirq/protocols/apply_unitary_protocol.py +++ b/cirq-core/cirq/protocols/apply_unitary_protocol.py @@ -11,7 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """A protocol for implementing high performance unitary left-multiplies.""" + import warnings from typing import Any, cast, Iterable, Optional, Sequence, Tuple, TYPE_CHECKING, TypeVar, Union diff --git a/cirq-core/cirq/protocols/circuit_diagram_info_protocol.py b/cirq-core/cirq/protocols/circuit_diagram_info_protocol.py index 5f9c5bbda39..f3eebe4f6b4 100644 --- a/cirq-core/cirq/protocols/circuit_diagram_info_protocol.py +++ b/cirq-core/cirq/protocols/circuit_diagram_info_protocol.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + import re from fractions import Fraction from typing import ( @@ -122,7 +126,6 @@ def _wire_symbols_including_formatted_exponent( return result def _formatted_exponent(self, args: 'cirq.CircuitDiagramInfoArgs') -> Optional[str]: - if protocols.is_parameterized(self.exponent): name = str(self.exponent) return f'({name})' if _is_exposed_formula(name) else name diff --git a/cirq-core/cirq/protocols/inverse_protocol.py b/cirq-core/cirq/protocols/inverse_protocol.py index 4e6ff15803c..6794ed0b742 100644 --- a/cirq-core/cirq/protocols/inverse_protocol.py +++ b/cirq-core/cirq/protocols/inverse_protocol.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Any, List, overload, Tuple, TYPE_CHECKING, TypeVar, Union, Iterable from cirq import ops diff --git a/cirq-core/cirq/protocols/kraus_protocol.py b/cirq-core/cirq/protocols/kraus_protocol.py index 5fe89052356..aabd5777a1c 100644 --- a/cirq-core/cirq/protocols/kraus_protocol.py +++ b/cirq-core/cirq/protocols/kraus_protocol.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Protocol and methods for obtaining Kraus representation of quantum channels.""" from typing import Any, Sequence, Tuple, TypeVar, Union diff --git a/cirq-core/cirq/protocols/mixture_protocol.py b/cirq-core/cirq/protocols/mixture_protocol.py index 646c0b0cd74..1e2fe22873c 100644 --- a/cirq-core/cirq/protocols/mixture_protocol.py +++ b/cirq-core/cirq/protocols/mixture_protocol.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Protocol for objects that are mixtures (probabilistic combinations).""" from typing import Any, Sequence, Tuple, Union diff --git a/cirq-core/cirq/protocols/phase_protocol.py b/cirq-core/cirq/protocols/phase_protocol.py index da072968ddb..42bced3142e 100644 --- a/cirq-core/cirq/protocols/phase_protocol.py +++ b/cirq-core/cirq/protocols/phase_protocol.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Any, TypeVar from typing_extensions import Protocol diff --git a/cirq-core/cirq/protocols/pow_protocol.py b/cirq-core/cirq/protocols/pow_protocol.py index 26e4e57353e..9840abb54ca 100644 --- a/cirq-core/cirq/protocols/pow_protocol.py +++ b/cirq-core/cirq/protocols/pow_protocol.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Any, Callable, Optional, overload, TypeVar, TYPE_CHECKING, Union if TYPE_CHECKING: diff --git a/cirq-core/cirq/protocols/qasm.py b/cirq-core/cirq/protocols/qasm.py index 34698428769..145c6de4eed 100644 --- a/cirq-core/cirq/protocols/qasm.py +++ b/cirq-core/cirq/protocols/qasm.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + import string from typing import TYPE_CHECKING, Union, Any, Tuple, TypeVar, Optional, Dict, Iterable diff --git a/cirq-core/cirq/protocols/qid_shape_protocol.py b/cirq-core/cirq/protocols/qid_shape_protocol.py index bb300496616..5349d39c80c 100644 --- a/cirq-core/cirq/protocols/qid_shape_protocol.py +++ b/cirq-core/cirq/protocols/qid_shape_protocol.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Any, Sequence, Tuple, TypeVar, Union from typing_extensions import Protocol diff --git a/cirq-core/cirq/protocols/unitary_protocol.py b/cirq-core/cirq/protocols/unitary_protocol.py index 4882dd96022..d56e02d2d2f 100644 --- a/cirq-core/cirq/protocols/unitary_protocol.py +++ b/cirq-core/cirq/protocols/unitary_protocol.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Any, TypeVar, Union, Optional import numpy as np diff --git a/cirq-core/cirq/qis/clifford_tableau.py b/cirq-core/cirq/qis/clifford_tableau.py index bd73daccf76..026919ac8bf 100644 --- a/cirq-core/cirq/qis/clifford_tableau.py +++ b/cirq-core/cirq/qis/clifford_tableau.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + import abc from typing import Any, Dict, List, Optional, Sequence, TYPE_CHECKING import numpy as np @@ -164,7 +167,7 @@ def __init__( def _reconstruct_rs(self, rs: Optional[np.ndarray]) -> np.ndarray: if rs is None: new_rs = np.zeros(2 * self.n + 1, dtype=bool) - for (i, val) in enumerate( + for i, val in enumerate( big_endian_int_to_digits(self.initial_state, digit_count=self.n, base=2) ): new_rs[self.n + i] = bool(val) @@ -203,7 +206,6 @@ def _reconstruct_xs(self, xs: Optional[np.ndarray]) -> np.ndarray: return new_xs def _reconstruct_zs(self, zs: Optional[np.ndarray]) -> np.ndarray: - if zs is None: new_zs = np.zeros((2 * self.n + 1, self.n), dtype=bool) for i in range(self.n): diff --git a/cirq-core/cirq/qis/states.py b/cirq-core/cirq/qis/states.py index 96e8924d9ae..e132139ff00 100644 --- a/cirq-core/cirq/qis/states.py +++ b/cirq-core/cirq/qis/states.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Classes and methods for quantum states.""" from typing import Any, cast, Iterable, List, Optional, Sequence, Set, TYPE_CHECKING, Tuple, Union diff --git a/cirq-core/cirq/sim/clifford/clifford_simulator.py b/cirq-core/cirq/sim/clifford/clifford_simulator.py index 5d41d8bb07b..e60f535fd9c 100644 --- a/cirq-core/cirq/sim/clifford/clifford_simulator.py +++ b/cirq-core/cirq/sim/clifford/clifford_simulator.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """An efficient simulator for Clifford circuits. Allowed operations include: @@ -109,7 +113,6 @@ def _create_simulator_trial_result( measurements: Dict[str, np.ndarray], final_simulator_state: 'cirq.SimulationStateBase[cirq.StabilizerChFormSimulationState]', ): - return CliffordTrialResult( params=params, measurements=measurements, final_simulator_state=final_simulator_state ) diff --git a/cirq-core/cirq/sim/density_matrix_simulation_state.py b/cirq-core/cirq/sim/density_matrix_simulation_state.py index 1b7c5fa6e21..c3d6e3365c2 100644 --- a/cirq-core/cirq/sim/density_matrix_simulation_state.py +++ b/cirq-core/cirq/sim/density_matrix_simulation_state.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Objects and methods for acting efficiently on a density matrix.""" from typing import Any, Callable, List, Optional, Sequence, Tuple, Type, TYPE_CHECKING, Union diff --git a/cirq-core/cirq/sim/density_matrix_utils.py b/cirq-core/cirq/sim/density_matrix_utils.py index bb3d87195e7..270907bc765 100644 --- a/cirq-core/cirq/sim/density_matrix_utils.py +++ b/cirq-core/cirq/sim/density_matrix_utils.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Code to handle density matrices.""" from typing import List, Optional, TYPE_CHECKING, Tuple, Sequence diff --git a/cirq-core/cirq/sim/mux.py b/cirq-core/cirq/sim/mux.py index b35216903e3..879bf2cb5f0 100644 --- a/cirq-core/cirq/sim/mux.py +++ b/cirq-core/cirq/sim/mux.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Sampling/simulation methods that delegate to appropriate simulators. Filename is a reference to multiplexing. diff --git a/cirq-core/cirq/sim/simulator.py b/cirq-core/cirq/sim/simulator.py index a4cbd25e54b..08dea32a410 100644 --- a/cirq-core/cirq/sim/simulator.py +++ b/cirq-core/cirq/sim/simulator.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Abstract base classes for different types of simulators. Simulator types include: diff --git a/cirq-core/cirq/sim/state_vector_simulation_state.py b/cirq-core/cirq/sim/state_vector_simulation_state.py index f721fb618a8..e25cac118d5 100644 --- a/cirq-core/cirq/sim/state_vector_simulation_state.py +++ b/cirq-core/cirq/sim/state_vector_simulation_state.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Objects and methods for acting efficiently on a state vector.""" from typing import Any, Callable, List, Optional, Sequence, Tuple, Type, TYPE_CHECKING, Union diff --git a/cirq-core/cirq/testing/circuit_compare.py b/cirq-core/cirq/testing/circuit_compare.py index 1b28279aea5..b22d16bd872 100644 --- a/cirq-core/cirq/testing/circuit_compare.py +++ b/cirq-core/cirq/testing/circuit_compare.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Any, Dict, Iterable, List, Optional, Sequence, Union from collections import defaultdict diff --git a/cirq-core/cirq/testing/consistent_act_on.py b/cirq-core/cirq/testing/consistent_act_on.py index 2942b40b1fa..881f12bc6c7 100644 --- a/cirq-core/cirq/testing/consistent_act_on.py +++ b/cirq-core/cirq/testing/consistent_act_on.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Any, cast, Optional, Type import numpy as np diff --git a/cirq-core/cirq/testing/consistent_protocols_test.py b/cirq-core/cirq/testing/consistent_protocols_test.py index 8d0c6d43b2f..16d0de662ee 100644 --- a/cirq-core/cirq/testing/consistent_protocols_test.py +++ b/cirq-core/cirq/testing/consistent_protocols_test.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import AbstractSet, Sequence, Union, List, Tuple import pytest diff --git a/cirq-core/cirq/testing/consistent_qasm.py b/cirq-core/cirq/testing/consistent_qasm.py index 6664da8c863..0cbaf4dc7be 100644 --- a/cirq-core/cirq/testing/consistent_qasm.py +++ b/cirq-core/cirq/testing/consistent_qasm.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + import warnings from typing import Any, List, Sequence, Optional diff --git a/cirq-core/cirq/testing/consistent_specified_has_unitary.py b/cirq-core/cirq/testing/consistent_specified_has_unitary.py index 7c709e0e66d..53c57109129 100644 --- a/cirq-core/cirq/testing/consistent_specified_has_unitary.py +++ b/cirq-core/cirq/testing/consistent_specified_has_unitary.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Any from cirq import protocols diff --git a/cirq-core/cirq/testing/equivalent_repr_eval.py b/cirq-core/cirq/testing/equivalent_repr_eval.py index b1e13fc3021..46a1a59769f 100644 --- a/cirq-core/cirq/testing/equivalent_repr_eval.py +++ b/cirq-core/cirq/testing/equivalent_repr_eval.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Any, Dict, Optional diff --git a/cirq-core/cirq/testing/order_tester.py b/cirq-core/cirq/testing/order_tester.py index f986b3a1713..a414bf5a6a6 100644 --- a/cirq-core/cirq/testing/order_tester.py +++ b/cirq-core/cirq/testing/order_tester.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """A utility class for testing ordering methods. To test an ordering method, create an OrderTester and add several diff --git a/cirq-core/cirq/transformers/analytical_decompositions/three_qubit_decomposition_test.py b/cirq-core/cirq/transformers/analytical_decompositions/three_qubit_decomposition_test.py index dce301acae9..fb4f6657b21 100644 --- a/cirq-core/cirq/transformers/analytical_decompositions/three_qubit_decomposition_test.py +++ b/cirq-core/cirq/transformers/analytical_decompositions/three_qubit_decomposition_test.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from random import random from typing import Callable diff --git a/cirq-core/cirq/value/abc_alt.py b/cirq-core/cirq/value/abc_alt.py index d4af63eb98d..af57df09353 100644 --- a/cirq-core/cirq/value/abc_alt.py +++ b/cirq-core/cirq/value/abc_alt.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """A more flexible abstract base class metaclass ABCMetaImplementAnyOneOf.""" import abc diff --git a/cirq-core/cirq/value/digits.py b/cirq-core/cirq/value/digits.py index 68def830a70..24b13f93e81 100644 --- a/cirq-core/cirq/value/digits.py +++ b/cirq-core/cirq/value/digits.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import List, Iterable, Any, Union, Optional, overload diff --git a/cirq-core/cirq/value/linear_dict.py b/cirq-core/cirq/value/linear_dict.py index 6b8e9d3a91d..1167711a404 100644 --- a/cirq-core/cirq/value/linear_dict.py +++ b/cirq-core/cirq/value/linear_dict.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Linear combination represented as mapping of things to coefficients.""" import numbers from typing import ( diff --git a/cirq-core/cirq/value/product_state.py b/cirq-core/cirq/value/product_state.py index bc5a7cc36c5..adf94da88a4 100644 --- a/cirq-core/cirq/value/product_state.py +++ b/cirq-core/cirq/value/product_state.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + import abc from dataclasses import dataclass from typing import Dict, Iterator, Optional, Sequence, Tuple, TYPE_CHECKING diff --git a/cirq-core/cirq/work/observable_settings.py b/cirq-core/cirq/work/observable_settings.py index 677297fbc91..ad246beac82 100644 --- a/cirq-core/cirq/work/observable_settings.py +++ b/cirq-core/cirq/work/observable_settings.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + import dataclasses import numbers from typing import ( diff --git a/cirq-google/cirq_google/api/v1/programs.py b/cirq-google/cirq_google/api/v1/programs.py index 256d5b86789..2d1df05b814 100644 --- a/cirq-google/cirq_google/api/v1/programs.py +++ b/cirq-google/cirq_google/api/v1/programs.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + import json from typing import Any, cast, Dict, Optional, Sequence, Tuple, TYPE_CHECKING, Iterator import numpy as np diff --git a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/client.py b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/client.py index c7b57431773..8ace008ff8f 100644 --- a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/client.py +++ b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/client.py @@ -166,7 +166,7 @@ def transport(self) -> QuantumEngineServiceTransport: @staticmethod def quantum_job_path(project: str,program: str,job: str,) -> str: """Returns a fully-qualified quantum_job string.""" - return "projects/{project}/programs/{program}/jobs/{job}".format(project=project, program=program, job=job, ) + return f"projects/{project}/programs/{program}/jobs/{job}" @staticmethod def parse_quantum_job_path(path: str) -> Dict[str,str]: @@ -177,7 +177,7 @@ def parse_quantum_job_path(path: str) -> Dict[str,str]: @staticmethod def quantum_processor_path(project_id: str,processor_id: str,) -> str: """Returns a fully-qualified quantum_processor string.""" - return "projects/{project_id}/processors/{processor_id}".format(project_id=project_id, processor_id=processor_id, ) + return f"projects/{project_id}/processors/{processor_id}" @staticmethod def parse_quantum_processor_path(path: str) -> Dict[str,str]: @@ -188,7 +188,7 @@ def parse_quantum_processor_path(path: str) -> Dict[str,str]: @staticmethod def quantum_program_path(project: str,program: str,) -> str: """Returns a fully-qualified quantum_program string.""" - return "projects/{project}/programs/{program}".format(project=project, program=program, ) + return f"projects/{project}/programs/{program}" @staticmethod def parse_quantum_program_path(path: str) -> Dict[str,str]: @@ -199,7 +199,7 @@ def parse_quantum_program_path(path: str) -> Dict[str,str]: @staticmethod def quantum_reservation_path(project_id: str,processor_id: str,reservation_id: str,) -> str: """Returns a fully-qualified quantum_reservation string.""" - return "projects/{project_id}/processors/{processor_id}/reservations/{reservation_id}".format(project_id=project_id, processor_id=processor_id, reservation_id=reservation_id, ) + return f"projects/{project_id}/processors/{processor_id}/reservations/{reservation_id}" @staticmethod def parse_quantum_reservation_path(path: str) -> Dict[str,str]: @@ -210,7 +210,7 @@ def parse_quantum_reservation_path(path: str) -> Dict[str,str]: @staticmethod def common_billing_account_path(billing_account: str, ) -> str: """Returns a fully-qualified billing_account string.""" - return "billingAccounts/{billing_account}".format(billing_account=billing_account, ) + return f"billingAccounts/{billing_account}" @staticmethod def parse_common_billing_account_path(path: str) -> Dict[str,str]: @@ -221,7 +221,7 @@ def parse_common_billing_account_path(path: str) -> Dict[str,str]: @staticmethod def common_folder_path(folder: str, ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder, ) + return f"folders/{folder}" @staticmethod def parse_common_folder_path(path: str) -> Dict[str,str]: @@ -232,7 +232,7 @@ def parse_common_folder_path(path: str) -> Dict[str,str]: @staticmethod def common_organization_path(organization: str, ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization, ) + return f"organizations/{organization}" @staticmethod def parse_common_organization_path(path: str) -> Dict[str,str]: @@ -243,7 +243,7 @@ def parse_common_organization_path(path: str) -> Dict[str,str]: @staticmethod def common_project_path(project: str, ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project, ) + return f"projects/{project}" @staticmethod def parse_common_project_path(path: str) -> Dict[str,str]: @@ -254,7 +254,7 @@ def parse_common_project_path(path: str) -> Dict[str,str]: @staticmethod def common_location_path(project: str, location: str, ) -> str: """Returns a fully-qualified location string.""" - return "projects/{project}/locations/{location}".format(project=project, location=location, ) + return f"projects/{project}/locations/{location}" @staticmethod def parse_common_location_path(path: str) -> Dict[str,str]: diff --git a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/pagers.py b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/pagers.py index 4df7598de6d..49b315de505 100644 --- a/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/pagers.py +++ b/cirq-google/cirq_google/cloud/quantum_v1alpha1/services/quantum_engine_service/pagers.py @@ -75,7 +75,7 @@ def __iter__(self) -> Iterator[quantum.QuantumProgram]: yield from page.programs def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' class ListQuantumProgramsAsyncPager: @@ -137,7 +137,7 @@ async def async_generator(): return async_generator() def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' class ListQuantumJobsPager: @@ -196,7 +196,7 @@ def __iter__(self) -> Iterator[quantum.QuantumJob]: yield from page.jobs def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' class ListQuantumJobsAsyncPager: @@ -258,7 +258,7 @@ async def async_generator(): return async_generator() def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' class ListQuantumJobEventsPager: @@ -317,7 +317,7 @@ def __iter__(self) -> Iterator[quantum.QuantumJobEvent]: yield from page.events def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' class ListQuantumJobEventsAsyncPager: @@ -379,7 +379,7 @@ async def async_generator(): return async_generator() def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' class ListQuantumProcessorsPager: @@ -438,7 +438,7 @@ def __iter__(self) -> Iterator[quantum.QuantumProcessor]: yield from page.processors def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' class ListQuantumProcessorsAsyncPager: @@ -500,7 +500,7 @@ async def async_generator(): return async_generator() def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' class ListQuantumCalibrationsPager: @@ -559,7 +559,7 @@ def __iter__(self) -> Iterator[quantum.QuantumCalibration]: yield from page.calibrations def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' class ListQuantumCalibrationsAsyncPager: @@ -621,7 +621,7 @@ async def async_generator(): return async_generator() def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' class ListQuantumReservationsPager: @@ -680,7 +680,7 @@ def __iter__(self) -> Iterator[quantum.QuantumReservation]: yield from page.reservations def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' class ListQuantumReservationsAsyncPager: @@ -742,7 +742,7 @@ async def async_generator(): return async_generator() def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' class ListQuantumReservationGrantsPager: @@ -801,7 +801,7 @@ def __iter__(self) -> Iterator[quantum.QuantumReservationGrant]: yield from page.reservation_grants def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' class ListQuantumReservationGrantsAsyncPager: @@ -863,7 +863,7 @@ async def async_generator(): return async_generator() def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' class ListQuantumReservationBudgetsPager: @@ -922,7 +922,7 @@ def __iter__(self) -> Iterator[quantum.QuantumReservationBudget]: yield from page.reservation_budgets def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' class ListQuantumReservationBudgetsAsyncPager: @@ -984,7 +984,7 @@ async def async_generator(): return async_generator() def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' class ListQuantumTimeSlotsPager: @@ -1043,7 +1043,7 @@ def __iter__(self) -> Iterator[quantum.QuantumTimeSlot]: yield from page.time_slots def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' class ListQuantumTimeSlotsAsyncPager: @@ -1105,4 +1105,4 @@ async def async_generator(): return async_generator() def __repr__(self) -> str: - return '{0}<{1!r}>'.format(self.__class__.__name__, self._response) + return f'{self.__class__.__name__}<{self._response!r}>' diff --git a/cirq-google/cirq_google/engine/calibration.py b/cirq-google/cirq_google/engine/calibration.py index 18dd442c694..4fd58b02b87 100644 --- a/cirq-google/cirq_google/engine/calibration.py +++ b/cirq-google/cirq_google/engine/calibration.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Calibration wrapper for calibrations returned from the Quantum Engine.""" from collections import abc, defaultdict diff --git a/cirq-google/cirq_google/engine/engine_processor.py b/cirq-google/cirq_google/engine/engine_processor.py index 38245ab1f65..526ccd310f5 100644 --- a/cirq-google/cirq_google/engine/engine_processor.py +++ b/cirq-google/cirq_google/engine/engine_processor.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + import datetime from typing import Dict, List, Optional, Sequence, TYPE_CHECKING, Union diff --git a/cirq-google/cirq_google/serialization/circuit_serializer.py b/cirq-google/cirq_google/serialization/circuit_serializer.py index 17e8d6af4f0..1895e85485a 100644 --- a/cirq-google/cirq_google/serialization/circuit_serializer.py +++ b/cirq-google/cirq_google/serialization/circuit_serializer.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Support for serializing and deserializing cirq_google.api.v2 protos.""" from typing import Any, Dict, List, Optional diff --git a/cirq-pasqal/cirq_pasqal/pasqal_device.py b/cirq-pasqal/cirq_pasqal/pasqal_device.py index d231e484200..8b6d822f2bb 100644 --- a/cirq-pasqal/cirq_pasqal/pasqal_device.py +++ b/cirq-pasqal/cirq_pasqal/pasqal_device.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Sequence, Any, Union, Dict import numpy as np import networkx as nx diff --git a/dev_tools/bash_scripts_test.py b/dev_tools/bash_scripts_test.py index 792bd582907..20d40ecfcd5 100644 --- a/dev_tools/bash_scripts_test.py +++ b/dev_tools/bash_scripts_test.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + import os import subprocess from typing import Iterable @@ -80,7 +83,6 @@ def run( @only_on_posix def test_pytest_changed_files_file_selection(tmpdir_factory): - result = run( script_file='check/pytest-changed-files', tmpdir_factory=tmpdir_factory, @@ -187,7 +189,6 @@ def test_pytest_changed_files_file_selection(tmpdir_factory): @only_on_posix def test_pytest_changed_files_branch_selection(tmpdir_factory): - result = run( script_file='check/pytest-changed-files', tmpdir_factory=tmpdir_factory, arg='HEAD' ) @@ -610,7 +611,6 @@ def test_incremental_format_branch_selection(tmpdir_factory): @only_on_posix def test_pylint_changed_files_file_selection(tmpdir_factory): - result = run( script_file='check/pylint-changed-files', tmpdir_factory=tmpdir_factory, diff --git a/dev_tools/conf/.pylintrc b/dev_tools/conf/.pylintrc index bfec12fe0e5..1f0496da6ff 100644 --- a/dev_tools/conf/.pylintrc +++ b/dev_tools/conf/.pylintrc @@ -15,6 +15,7 @@ enable= bad-reversed-sequence, bad-super-call, consider-merging-isinstance, + consider-using-f-string, continue-in-finally, dangerous-default-value, docstyle, diff --git a/dev_tools/incremental_coverage.py b/dev_tools/incremental_coverage.py index a35b4d6459f..29da204aa21 100644 --- a/dev_tools/incremental_coverage.py +++ b/dev_tools/incremental_coverage.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + from typing import Dict, Tuple, List, cast, Set, Optional import os.path diff --git a/dev_tools/pr_monitor.py b/dev_tools/pr_monitor.py index f7257ecd113..1bb94f723ae 100644 --- a/dev_tools/pr_monitor.py +++ b/dev_tools/pr_monitor.py @@ -1,4 +1,8 @@ # pylint: disable=wrong-or-nonexistent-copyright-notice + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Code to interact with GitHub API to label and auto-merge pull requests.""" import datetime diff --git a/dev_tools/prepared_env.py b/dev_tools/prepared_env.py index 50cf66acee1..fd7572a1ace 100644 --- a/dev_tools/prepared_env.py +++ b/dev_tools/prepared_env.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + import sys from typing import List, Optional diff --git a/dev_tools/profiling/benchmark_simulators.py b/dev_tools/profiling/benchmark_simulators.py index 953c9af3590..7d057388066 100644 --- a/dev_tools/profiling/benchmark_simulators.py +++ b/dev_tools/profiling/benchmark_simulators.py @@ -12,6 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Tool to benchmarking simulators against a random circuit.""" import argparse diff --git a/dev_tools/snippets_test.py b/dev_tools/snippets_test.py index 9b6aec48a56..02b269edd71 100644 --- a/dev_tools/snippets_test.py +++ b/dev_tools/snippets_test.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Tests for executable snippets in documentation. This tests runs code snippets that are executable in `.md` and `.rst` diff --git a/examples/bernstein_vazirani.py b/examples/bernstein_vazirani.py index 2990b1df73c..ff6ebdc4319 100644 --- a/examples/bernstein_vazirani.py +++ b/examples/bernstein_vazirani.py @@ -1,4 +1,8 @@ # pylint: disable=wrong-or-nonexistent-copyright-notice + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Demonstrates the Bernstein-Vazirani algorithm. The (non-recursive) Bernstein-Vazirani algorithm takes a black-box oracle diff --git a/examples/swap_networks.py b/examples/swap_networks.py index 69642a77b9d..a6c7ba85f10 100644 --- a/examples/swap_networks.py +++ b/examples/swap_networks.py @@ -1,4 +1,8 @@ # pylint: disable=wrong-or-nonexistent-copyright-notice + +# TODO(#6171): enable the check and fix pylint errors +# pylint: disable=consider-using-f-string + """Demonstrates swap networks. Swap networks are used to get around limited connectivity in a hardware device.