Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 1 addition & 17 deletions cirq-core/cirq/_compat_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,11 @@ def old_func(*args, **kwargs):
old_func(1, 2)

with pytest.raises(AssertionError, match='deadline should match vX.Y'):
# pylint: disable=unused-variable

@deprecated(deadline='invalid', fix='Roll some dice.')
def badly_deprecated_func(*args, **kwargs): # pragma: no cover
return new_func(*args, **kwargs)

# pylint: enable=unused-variable


def test_deprecated_parameter():
@deprecated_parameter(
Expand All @@ -234,20 +232,16 @@ def f(new_count):
'Double it yourself.',
deadline='v1.2',
):
# pylint: disable=unexpected-keyword-arg
# pylint: disable=no-value-for-parameter
assert f(double_count=1) == 2
# pylint: enable=no-value-for-parameter
# pylint: enable=unexpected-keyword-arg

with pytest.raises(
ValueError, match='During testing using Cirq deprecated functionality is not allowed'
):
# pylint: disable=unexpected-keyword-arg
# pylint: disable=no-value-for-parameter
f(double_count=1)
# pylint: enable=no-value-for-parameter
# pylint: enable=unexpected-keyword-arg

with pytest.raises(AssertionError, match='deadline should match vX.Y'):

Expand All @@ -259,12 +253,9 @@ def f(new_count):
match=lambda args, kwargs: 'double_count' in kwargs,
rewrite=lambda args, kwargs: (args, {'new_count': kwargs['double_count'] * 2}),
)
# pylint: disable=unused-variable
def f_with_badly_deprecated_param(new_count): # pragma: no cover
return new_count

# pylint: enable=unused-variable


@duet.sync
async def test_deprecated_parameter_async_function():
Expand Down Expand Up @@ -293,11 +284,9 @@ async def f(new_count):
'Double it yourself.',
deadline='v1.2',
):
# pylint: disable=unexpected-keyword-arg
# pylint: disable=no-value-for-parameter
assert await f(double_count=1) == 2
# pylint: enable=no-value-for-parameter
# pylint: enable=unexpected-keyword-arg


def test_wrap_module():
Expand Down Expand Up @@ -587,7 +576,6 @@ def _repeated_import_path():

def _type_repr_in_deprecated_module():
# initialize the DeprecatedModuleFinders
# pylint: disable=unused-import
import cirq.testing._compat_test_data.fake_a as mod_a

expected_repr = "<class 'cirq.testing._compat_test_data.module_a.types.SampleType'>"
Expand Down Expand Up @@ -763,8 +751,6 @@ def test_metadata_search_path():

def _test_metadata_search_path_inner(): # pragma: no cover
# initialize the DeprecatedModuleFinders
# pylint: disable=unused-import

assert importlib.metadata.metadata('numpy')


Expand Down Expand Up @@ -805,7 +791,6 @@ def test_type_repr_in_new_module():

def _test_type_repr_in_new_module_inner():
# initialize the DeprecatedModuleFinders
# pylint: disable=unused-import
import cirq.testing._compat_test_data.module_a as mod_a

expected_repr = "<class 'cirq.testing._compat_test_data.module_a.types.SampleType'>"
Expand Down Expand Up @@ -875,7 +860,6 @@ def test_new_module_is_top_level():

def _test_new_module_is_top_level_inner():
# sets up the DeprecationFinders
# pylint: disable=unused-import
import time

# imports a top level module that was also deprecated
Expand Down
6 changes: 0 additions & 6 deletions cirq-core/cirq/circuits/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ def _decompose_(self) -> cirq.OP_TREE:
"""See `cirq.SupportsDecompose`."""
return self.all_operations()

# pylint: disable=function-redefined
@overload
def __getitem__(self, key: int) -> cirq.Moment:
pass
Expand Down Expand Up @@ -277,8 +276,6 @@ def __getitem__(self, key):

raise TypeError('__getitem__ called with key not of type slice, int, or tuple.')

# pylint: enable=function-redefined

def __str__(self) -> str:
return self.to_text_diagram()

Expand Down Expand Up @@ -1895,7 +1892,6 @@ def copy(self) -> Circuit:
copied_circuit._placement_cache = None
return copied_circuit

# pylint: disable=function-redefined
@overload
def __setitem__(self, key: int, value: cirq.Moment):
pass
Expand All @@ -1916,8 +1912,6 @@ def __setitem__(self, key, value):
self._moments[key] = value
self._mutated()

# pylint: enable=function-redefined

def __delitem__(self, key: int | slice):
del self._moments[key]
self._mutated()
Expand Down
1 change: 0 additions & 1 deletion cirq-core/cirq/circuits/moment.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,6 @@ def __sub__(self, other: cirq.OP_TREE) -> cirq.Moment:
)
return Moment(new_ops)

# pylint: disable=function-redefined
@overload
def __getitem__(self, key: raw_types.Qid) -> cirq.Operation:
pass
Expand Down
9 changes: 5 additions & 4 deletions cirq-core/cirq/contrib/acquaintance/bipartite_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,11 @@
│ │ │ │
3: ─────────────█───1↦0───────█───1↦0─────────────
""",
('decomposed', cca.BipartiteGraphType.COMPLETE, 3):
# pylint: disable=line-too-long
"""
(
'decomposed',
cca.BipartiteGraphType.COMPLETE,
3,
): """
0: ───────────────────────█───0↦1───────────────────────────█───0↦1───────────────────────
│ │ │ │
1: ─────────────█───0↦1───█───1↦0───█───0↦1───────█───0↦1───█───1↦0───█───0↦1─────────────
Expand Down Expand Up @@ -202,7 +204,6 @@
7: ─────────────────────────────────█───1↦0───────────────────────────────────────────────█───1↦0─────────────────────────────────

""",
# pylint: enable=line-too-long
(
'decomposed',
cca.BipartiteGraphType.MATCHING,
Expand Down
1 change: 0 additions & 1 deletion cirq-core/cirq/contrib/quirk/quirk_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def single_qubit_matrix_gate(matrix: np.ndarray | None) -> QuirkOp | None:
if matrix is None or matrix.shape[0] != 2:
return None

# pylint: disable=consider-using-f-string
matrix = matrix.round(6)
matrix_repr = '{{%s+%si,%s+%si},{%s+%si,%s+%si}}' % (
np.real(matrix[0, 0]),
Expand Down
1 change: 0 additions & 1 deletion cirq-core/cirq/linalg/decompositions.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def unitary_eig(
return R.diagonal(), V


# pylint: enable=missing-raises-doc
def map_eigenvalues(
matrix: np.ndarray, func: Callable[[complex], complex], *, atol: float = 1e-8
) -> np.ndarray:
Expand Down
6 changes: 1 addition & 5 deletions cirq-core/cirq/ops/clifford_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,11 +747,7 @@ def __pow__(self, exponent: float) -> SingleQubitCliffordGate:

return NotImplemented

def _act_on_(
self,
sim_state: cirq.SimulationStateBase, # pylint: disable=unused-argument
qubits: Sequence[cirq.Qid], # pylint: disable=unused-argument
):
def _act_on_(self, sim_state: cirq.SimulationStateBase, qubits: Sequence[cirq.Qid]):
# TODO(#5256) Add the implementation of _act_on_ with CliffordTableauSimulationState.
return NotImplemented

Expand Down
2 changes: 0 additions & 2 deletions cirq-core/cirq/ops/eigen_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,9 @@ def _with_exponent(self, exponent: value.TParamVal) -> EigenGate:
Child classes should override this method if they have an __init__
method with a differing signature.
"""
# pylint: disable=unexpected-keyword-arg
if self._global_shift == 0:
return type(self)(exponent=exponent)
return type(self)(exponent=exponent, global_shift=self._global_shift)
# pylint: enable=unexpected-keyword-arg

def _diagram_exponent(
self, args: protocols.CircuitDiagramInfoArgs, *, ignore_global_phase: bool = True
Expand Down
6 changes: 0 additions & 6 deletions cirq-core/cirq/ops/measure_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ def measure_paulistring_terms(
return [PauliMeasurementGate([pauli_basis[q]], key=key_func(q)).on(q) for q in pauli_basis]


# pylint: disable=function-redefined


@overload
def measure(
*target: raw_types.Qid,
Expand Down Expand Up @@ -205,6 +202,3 @@ def measure_each(
)
qubitsequence = qubits[0] if one_iterable_arg else qubits
return [MeasurementGate(1, key_func(q), qid_shape=(q.dimension,)).on(q) for q in qubitsequence]


# pylint: enable=function-redefined
7 changes: 0 additions & 7 deletions cirq-core/cirq/ops/pauli_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ def equal_up_to_coefficient(self, other: cirq.PauliString) -> bool:
def __getitem__(self, key: TKey) -> pauli_gates.Pauli:
return self._qubit_pauli_map[key]

# pylint: disable=function-redefined
@overload
def get(self, key: Any, default: None = None) -> pauli_gates.Pauli | None:
pass
Expand Down Expand Up @@ -281,8 +280,6 @@ def __mul__(self, other):
)
return NotImplemented

# pylint: enable=function-redefined

@property
def gate(self) -> cirq.DensePauliString:
"""Returns a `cirq.DensePauliString`"""
Expand Down Expand Up @@ -897,9 +894,7 @@ def dense(self, qubits: Sequence[TKey]) -> cirq.DensePauliString:

if not self.keys() <= set(qubits):
raise ValueError('not self.keys() <= set(qubits)')
# pylint: disable=too-many-function-args
pauli_mask = [self.get(q, identity.I) for q in qubits]
# pylint: enable=too-many-function-args
return dense_pauli_string.DensePauliString(pauli_mask, coefficient=self.coefficient)

def conjugated_by(self, clifford: cirq.OP_TREE) -> PauliString:
Expand Down Expand Up @@ -1349,7 +1344,6 @@ def __setitem__(self, key: TKey, value: cirq.PAULI_GATE_LIKE):
def __delitem__(self, key: TKey):
del self.pauli_int_dict[key]

# pylint: disable=function-redefined
@overload
def get(self, key: TKey, default: None = None) -> cirq.Pauli | None:
pass
Expand All @@ -1363,7 +1357,6 @@ def get(self, key: TKey, default=None) -> cirq.Pauli | TDefault | None:
result = self.pauli_int_dict.get(key, None)
return default if result is None else _INT_TO_PAULI[result - 1]

# pylint: enable=function-redefined
def inplace_before(self, ops: cirq.OP_TREE) -> cirq.MutablePauliString:
r"""Propagates the pauli string from after to before a Clifford effect.

Expand Down
2 changes: 0 additions & 2 deletions cirq-core/cirq/ops/pauli_string_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,7 @@ def test_get(qubit_pauli_map):
assert qubit_pauli_map.get(key) == pauli_string.get(key)
assert qubit_pauli_map.get(other) is None
assert pauli_string.get(other) is None
# pylint: disable=too-many-function-args
assert qubit_pauli_map.get(other, 5) == pauli_string.get(other, 5) == 5
# pylint: enable=too-many-function-args


@pytest.mark.parametrize('qubit_pauli_map', _sample_qubit_pauli_maps())
Expand Down
1 change: 0 additions & 1 deletion cirq-core/cirq/ops/three_qubit_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
)

if TYPE_CHECKING:
# pylint: disable=unused-import
import cirq


Expand Down
4 changes: 0 additions & 4 deletions cirq-core/cirq/protocols/circuit_diagram_info_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ def _op_info_with_fallback(
return protocols.CircuitDiagramInfo(wire_symbols=symbols)


# pylint: disable=function-redefined
@overload
def circuit_diagram_info(
val: Any, args: CircuitDiagramInfoArgs | None = None
Expand Down Expand Up @@ -429,6 +428,3 @@ def circuit_diagram_info(
f"object of type '{type(val)}' does have a _circuit_diagram_info_ "
"method, but it returned NotImplemented."
)


# pylint: enable=function-redefined
6 changes: 0 additions & 6 deletions cirq-core/cirq/protocols/decompose_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,6 @@ def decompose(
return [*_decompose_dfs(val, args)]


# pylint: disable=function-redefined


@overload
def decompose_once(val: Any, **kwargs) -> list[cirq.Operation]:
pass
Expand Down Expand Up @@ -452,9 +449,6 @@ def decompose_once_with_qubits(
return decompose_once(val, default, tuple(qubits), flatten=flatten, context=context)


# pylint: enable=function-redefined


def _try_decompose_into_operations_and_qubits(
val: Any,
) -> tuple[list[cirq.Operation] | None, Sequence[cirq.Qid], tuple[int, ...]]:
Expand Down
5 changes: 0 additions & 5 deletions cirq-core/cirq/protocols/inverse_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
TDefault = TypeVar('TDefault')


# pylint: disable=function-redefined
@overload
def inverse(val: cirq.Gate) -> cirq.Gate:
pass
Expand Down Expand Up @@ -100,7 +99,6 @@ def inverse(val: Any, default: Any = RaiseTypeErrorIfNotProvided) -> Any:
# Check if object defines an inverse via __pow__.
raiser = getattr(val, '__pow__', None)

# pylint: disable=not-callable
result = NotImplemented if raiser is None else raiser(-1)
if result is not NotImplemented:
return result
Expand All @@ -121,6 +119,3 @@ def inverse(val: Any, default: Any = RaiseTypeErrorIfNotProvided) -> Any:
"It has no __pow__ method (or the method returned NotImplemented) "
"and it isn't an iterable of invertible objects."
)


# pylint: enable=function-redefined
3 changes: 0 additions & 3 deletions cirq-core/cirq/protocols/json_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ def obj_to_dict_helper(obj: Any, attribute_names: Iterable[str]) -> dict[str, An
return d


# pylint: enable=redefined-builtin
def dataclass_json_dict(obj: Any) -> dict[str, Any]:
"""Return a dictionary suitable for `_json_dict_` from a dataclass.

Expand Down Expand Up @@ -460,7 +459,6 @@ def cirq_type_from_json(type_str: str, resolvers: Sequence[JsonResolver] | None
raise ValueError(f"Type {type_str} maps to a factory method instead of a type.")


# pylint: disable=function-redefined
@overload
def to_json(
obj: Any, file_or_fn: IO | pathlib.Path | str, *, indent=2, separators=None, cls=CirqEncoder
Expand Down Expand Up @@ -517,7 +515,6 @@ def to_json(
return None


# pylint: enable=function-redefined
def read_json(
file_or_fn: None | IO | pathlib.Path | str = None,
*,
Expand Down
3 changes: 0 additions & 3 deletions cirq-core/cirq/protocols/mul_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,3 @@ def mul(lhs: Any, rhs: Any, default: Any = RaiseTypeErrorIfNotProvided) -> Any:
if default is not RaiseTypeErrorIfNotProvided:
return default
raise TypeError(f"unsupported operand type(s) for *: '{type(lhs)}' and '{type(rhs)}'")


# pylint: enable=function-redefined, redefined-builtin
7 changes: 2 additions & 5 deletions cirq-core/cirq/protocols/pow_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
TDefault = TypeVar('TDefault')


# pylint: disable=function-redefined, redefined-builtin
# pylint: disable=redefined-builtin
@overload
def pow(val: cirq.Gate, exponent: Any) -> cirq.Gate:
pass
Expand Down Expand Up @@ -57,7 +57,7 @@ def pow(val: Any, exponent: Any, default: TDefault) -> Any:
pass


# pylint: enable=function-redefined
# pylint: enable=redefined-builtin


def pow(val: Any, exponent: Any, default: Any = RaiseTypeErrorIfNotProvided) -> Any:
Expand Down Expand Up @@ -96,6 +96,3 @@ def pow(val: Any, exponent: Any, default: Any = RaiseTypeErrorIfNotProvided) ->
raise TypeError(
f"object of type '{type(val)}' does have a __pow__ method, but it returned NotImplemented."
)


# pylint: enable=redefined-builtin
Loading
Loading