Skip to content

Commit 8e70f77

Browse files
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 <[email protected]>
1 parent 3fe3438 commit 8e70f77

File tree

74 files changed

+275
-48
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+275
-48
lines changed

cirq-core/cirq/_compat_test.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,8 @@ def old_func(*args, **kwargs):
200200

201201
with pytest.raises(AssertionError, match='deadline should match vX.Y'):
202202
# pylint: disable=unused-variable
203-
# coverage: ignore
204203
@deprecated(deadline='invalid', fix='Roll some dice.')
205-
def badly_deprecated_func(*args, **kwargs):
204+
def badly_deprecated_func(*args, **kwargs): # pragma: no cover
206205
return new_func(*args, **kwargs)
207206

208207
# pylint: enable=unused-variable
@@ -258,8 +257,7 @@ def f(new_count):
258257
rewrite=lambda args, kwargs: (args, {'new_count': kwargs['double_count'] * 2}),
259258
)
260259
# pylint: disable=unused-variable
261-
# coverage: ignore
262-
def f_with_badly_deprecated_param(new_count):
260+
def f_with_badly_deprecated_param(new_count): # pragma: no cover
263261
return new_count
264262

265263
# pylint: enable=unused-variable
@@ -371,9 +369,8 @@ class OldClass(NewClass):
371369

372370
with pytest.raises(AssertionError, match='deadline should match vX.Y'):
373371
# pylint: disable=unused-variable
374-
# coverage: ignore
375372
@deprecated_class(deadline='invalid', fix='theFix', name='foo')
376-
class BadlyDeprecatedClass(NewClass):
373+
class BadlyDeprecatedClass(NewClass): # pragma: no cover
377374
...
378375

379376
# pylint: enable=unused-variable
@@ -619,8 +616,6 @@ def subprocess_context(test_func):
619616
"it to this method?"
620617
)
621618

622-
import os
623-
624619
ctx = multiprocessing.get_context('spawn' if os.name == 'nt' else 'fork')
625620

626621
exception = ctx.Queue()
@@ -632,8 +627,7 @@ def isolated_func(*args, **kwargs):
632627
p.start()
633628
p.join()
634629
result = exception.get()
635-
if result:
636-
# coverage: ignore
630+
if result: # pragma: no cover
637631
ex_type, msg, ex_trace = result
638632
if ex_type == "Skipped":
639633
warnings.warn(f"Skipping: {ex_type}: {msg}\n{ex_trace}")
@@ -727,7 +721,7 @@ def _test_metadata_search_path_inner(): # pragma: no cover
727721
# pylint: disable=unused-import
728722
import cirq.testing._compat_test_data.module_a
729723

730-
assert importlib.metadata.metadata('flynt')
724+
assert importlib.metadata.metadata('numpy')
731725

732726

733727
def test_metadata_distributions_after_deprecated_submodule():

cirq-core/cirq/circuits/_block_diagram_drawer_test.py

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1418
import itertools
1519

1620
import pytest

cirq-core/cirq/circuits/circuit_operation.py

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1418
"""A structure for encapsulating entire circuits in an operation.
1519
1620
A CircuitOperation is an Operation object that wraps a FrozenCircuit. When

cirq-core/cirq/circuits/text_diagram_drawer_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
from unittest import mock
1619
import pytest
1720

cirq-core/cirq/contrib/acquaintance/bipartite.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
import enum
1619
import itertools
1720
from typing import Dict, Sequence, Tuple, Union, TYPE_CHECKING

cirq-core/cirq/contrib/acquaintance/devices.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
from typing import Union, TYPE_CHECKING
1619

1720
import abc

cirq-core/cirq/contrib/acquaintance/gates.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
import functools
1619
import itertools
1720
import math

cirq-core/cirq/contrib/acquaintance/testing.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
from typing import cast, Sequence, TYPE_CHECKING
1619

1720
from cirq import devices, ops, protocols

cirq-core/cirq/contrib/paulistring/recombine.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
from typing import Any, Callable, Iterable, Sequence, Tuple, Union, cast, List
1619

1720
from cirq import circuits, ops, protocols
@@ -27,7 +30,6 @@ def _sorted_best_string_placements(
2730
output_ops: Sequence[ops.Operation],
2831
key: Callable[[Any], ops.PauliStringPhasor] = lambda node: node.val,
2932
) -> List[Tuple[ops.PauliStringPhasor, int, circuitdag.Unique[ops.PauliStringPhasor]]]:
30-
3133
sort_key = lambda placement: (-len(placement[0].pauli_string), placement[1])
3234

3335
node_maxes = []
@@ -84,7 +86,6 @@ def move_pauli_strings_into_circuit(
8486
# Pick the Pauli string that can be moved furthest through
8587
# the Clifford circuit
8688
for best_string_op, best_index, best_node in placements:
87-
8889
assert (
8990
best_index <= last_index
9091
), "Unexpected insertion index order, {} >= {}, len: {}".format(

cirq-core/cirq/contrib/qasm_import/_parser.py

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1418
import functools
1519
import operator
1620
from typing import Any, Callable, cast, Dict, Iterable, List, Optional, Union, TYPE_CHECKING

cirq-core/cirq/contrib/qasm_import/_parser_test.py

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1418
from typing import Callable
1519

1620
import numpy as np

cirq-core/cirq/contrib/qcircuit/qcircuit_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
import cirq
1619
import cirq.contrib.qcircuit as ccq
1720
import cirq.testing as ct

cirq-core/cirq/contrib/quirk/quirk_gate.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
from typing import Any, Callable, cast, Dict, Optional, Union
1619

1720
import numpy as np

cirq-core/cirq/devices/noise_model.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
from typing import Any, Dict, Iterable, Sequence, TYPE_CHECKING, Union, Callable
1619

1720
from cirq import ops, protocols, value

cirq-core/cirq/linalg/diagonalize_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
import random
1619
from typing import Tuple, Optional
1720

cirq-core/cirq/linalg/transformations.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
"""Utility methods for transforming matrices or vectors."""
1619

1720
import dataclasses

cirq-core/cirq/ops/clifford_gate.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
from typing import Any, Dict, List, Optional, Sequence, Tuple, TYPE_CHECKING, Union
1619

1720

@@ -434,7 +437,6 @@ def _decompose_(self, qubits: Sequence['cirq.Qid']) -> 'cirq.OP_TREE':
434437
def _act_on_(
435438
self, sim_state: 'cirq.SimulationStateBase', qubits: Sequence['cirq.Qid']
436439
) -> Union[NotImplementedType, bool]:
437-
438440
# Note the computation complexity difference between _decompose_ and _act_on_.
439441
# Suppose this Gate has `m` qubits, args has `n` qubits, and the decomposition of
440442
# this operation into `k` operations:

cirq-core/cirq/ops/common_gate_families.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
"""Common Gate Families used in cirq-core"""
1619

1720
from typing import Any, cast, Optional, Type, Union

cirq-core/cirq/ops/common_gates.py

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1418
"""Quantum gates that are commonly used in the literature.
1519
1620
This module creates Gate instances for the following gates:

cirq-core/cirq/ops/diagonal_gate.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
"""Creates the gate instance for any number qubits diagonal gate.
1619
1720
The gate is used to create a (2^n)x(2^n) matrix with the diagonal elements

cirq-core/cirq/ops/gateset_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
from typing import Tuple, List, cast
1619
import re
1720
import pytest

cirq-core/cirq/ops/linear_combinations.py

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1418
from collections import defaultdict
1519
from typing import (
1620
AbstractSet,

cirq-core/cirq/ops/raw_types.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
"""Basic types defining qubits, gates, and operations."""
1619

1720
import abc

cirq-core/cirq/ops/three_qubit_gates.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
"""Common quantum gates that target three qubits."""
1619

1720
from typing import (

cirq-core/cirq/ops/two_qubit_diagonal_gate.py

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1418
"""Creates the gate instance for a two qubit diagonal gate.
1519
1620
The gate is used to create a 4x4 matrix with the diagonal elements

cirq-core/cirq/protocols/apply_channel_protocol.py

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1418
"""A protocol for implementing high performance channel evolutions."""
1519

1620
from typing import Any, Iterable, Optional, Sequence, TypeVar, Tuple, Union

cirq-core/cirq/protocols/apply_mixture_protocol.py

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1418
"""A protocol for implementing high performance mixture evolutions."""
1519

1620
from typing import Any, cast, Iterable, Optional, Tuple, TypeVar, Union

cirq-core/cirq/protocols/apply_unitary_protocol.py

+5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1418
"""A protocol for implementing high performance unitary left-multiplies."""
19+
1520
import warnings
1621
from typing import Any, cast, Iterable, Optional, Sequence, Tuple, TYPE_CHECKING, TypeVar, Union
1722

cirq-core/cirq/protocols/circuit_diagram_info_protocol.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1418
import re
1519
from fractions import Fraction
1620
from typing import (
@@ -122,7 +126,6 @@ def _wire_symbols_including_formatted_exponent(
122126
return result
123127

124128
def _formatted_exponent(self, args: 'cirq.CircuitDiagramInfoArgs') -> Optional[str]:
125-
126129
if protocols.is_parameterized(self.exponent):
127130
name = str(self.exponent)
128131
return f'({name})' if _is_exposed_formula(name) else name

cirq-core/cirq/protocols/inverse_protocol.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
# TODO(#6171): enable the check and fix pylint errors
16+
# pylint: disable=consider-using-f-string
17+
1518
from typing import Any, List, overload, Tuple, TYPE_CHECKING, TypeVar, Union, Iterable
1619

1720
from cirq import ops

0 commit comments

Comments
 (0)