Skip to content

Commit

Permalink
- Replaced type_workarounds.NotImplementedType with types.NotImplemen…
Browse files Browse the repository at this point in the history
…tedType

- Updated code to use Python 3.10's built-in types.NotImplementedType,
removing the need for the type_workarounds module.

This change simplifies
the codebase by relying on standard types, allowing us to delete the
now-redundant type_workarounds.py file.
  • Loading branch information
Ayobami-00 committed Nov 12, 2024
1 parent d1b0430 commit 2f747de
Show file tree
Hide file tree
Showing 39 changed files with 38 additions and 61 deletions.
2 changes: 1 addition & 1 deletion cirq-core/cirq/circuits/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
from cirq.circuits.qasm_output import QasmOutput
from cirq.circuits.text_diagram_drawer import TextDiagramDrawer
from cirq.protocols import circuit_diagram_info_protocol
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/circuits/frozen_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from cirq import protocols, _compat
from cirq.circuits import AbstractCircuit, Alignment, Circuit
from cirq.circuits.insert_strategy import InsertStrategy
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/circuits/moment.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from cirq._import import LazyLoader
from cirq.ops import raw_types, op_tree
from cirq.protocols import circuit_diagram_info_protocol
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/contrib/acquaintance/permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)

from cirq import circuits, ops, protocols, transformers, value
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import numpy as np

from cirq import ops, transformers, protocols, linalg
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/clifford_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from cirq._compat import cached_method
from cirq.ops import common_gates, named_qubit, raw_types, pauli_gates, phased_x_z_gate
from cirq.ops.pauli_gates import Pauli
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/common_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from cirq._doc import document
from cirq.ops import controlled_gate, eigen_gate, gate_features, raw_types, control_values as cv

from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

from cirq.ops.swap_gates import ISWAP, SWAP, ISwapPowGate, SwapPowGate
from cirq.ops.measurement_gate import MeasurementGate
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/controlled_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
matrix_gates,
control_values as cv,
)
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/controlled_gate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import sympy

import cirq
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType


class GateUsingWorkspaceForApplyUnitary(cirq.testing.SingleQubitGate):
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/controlled_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
raw_types,
control_values as cv,
)
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/controlled_operation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import cirq
from cirq import protocols
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType


class GateUsingWorkspaceForApplyUnitary(cirq.testing.SingleQubitGate):
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/dense_pauli_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from cirq import protocols, linalg, value
from cirq._compat import proper_repr
from cirq.ops import raw_types, identity, pauli_gates, global_phase_op, pauli_string
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/eigen_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from cirq import value, protocols
from cirq.linalg import tolerance
from cirq.ops import raw_types
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/gate_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

from cirq import ops, protocols, value
from cirq.ops import raw_types, gate_features, control_values as cv
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/global_phase_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import cirq
from cirq import value, protocols
from cirq.ops import raw_types, controlled_gate, control_values as cv
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType


@value.value_equality(approximate=True)
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from cirq import protocols, value
from cirq._doc import document
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType
from cirq.ops import raw_types

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/parallel_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from cirq import protocols, value
from cirq.ops import raw_types
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/pauli_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from cirq._doc import document
from cirq._import import LazyLoader
from cirq.ops import common_gates, raw_types, identity
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType


if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/pauli_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
pauli_interaction_gate,
raw_types,
)
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/phased_x_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from cirq import value, protocols
from cirq._compat import proper_repr
from cirq.ops import common_gates, raw_types
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType


@value.value_equality(manual_cls=True, approximate=True)
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/ops/raw_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from cirq import protocols, value
from cirq._import import LazyLoader
from cirq._compat import __cirq_debug__, _method_cache_name, cached_method
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType
from cirq.ops import control_values as cv

# Lazy imports to break circular dependencies.
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/protocols/act_on_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from cirq import ops
from cirq._doc import doc_private
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/protocols/apply_channel_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from cirq.protocols.apply_unitary_protocol import apply_unitary, ApplyUnitaryArgs
from cirq.protocols.kraus_protocol import kraus
from cirq.protocols import qid_shape_protocol
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

# This is a special indicator value used by the apply_channel method
# to determine whether or not the caller provided a 'default' argument. It must
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/protocols/apply_mixture_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from cirq.protocols.mixture_protocol import mixture
from cirq.protocols import qid_shape_protocol
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

# This is a special indicator value used by the apply_mixture method
# to determine whether or not the caller provided a 'default' argument. It must
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/protocols/apply_unitary_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from cirq._doc import doc_private
from cirq.protocols import qid_shape_protocol
from cirq.protocols.decompose_protocol import _try_decompose_into_operations_and_qubits
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/protocols/commutes_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from cirq import linalg
from cirq._doc import doc_private
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

# This is a special indicator value used by the unitary method to determine
# whether or not the caller provided a 'default' argument.
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/protocols/control_key_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from cirq._doc import doc_private
from cirq.protocols import measurement_key_protocol
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/protocols/decompose_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from cirq import devices, ops
from cirq._doc import doc_private
from cirq.protocols import qid_shape_protocol
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/protocols/json_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from typing_extensions import Protocol

from cirq._doc import doc_private
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

ObjectFactory = Union[Type, Callable[..., Any]]

Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/protocols/kraus_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from cirq.protocols.mixture_protocol import has_mixture


from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType


# This is a special indicator value used by the channel method to determine
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/protocols/measurement_key_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from cirq import value
from cirq._doc import doc_private
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/protocols/mixture_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from cirq._doc import doc_private
from cirq.protocols.decompose_protocol import _try_decompose_into_operations_and_qubits
from cirq.protocols.has_unitary_protocol import has_unitary
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

# This is a special indicator value used by the inverse method to determine
# whether or not the caller provided a 'default' argument.
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/protocols/qasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from cirq import ops
from cirq._doc import doc_private
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/protocols/qid_shape_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from cirq import ops
from cirq._doc import document, doc_private
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

# This is a special indicator value used by the methods to determine whether or
# not the caller provided a 'default' argument. It must be of type
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/protocols/unitary_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from cirq.protocols import qid_shape_protocol
from cirq.protocols.apply_unitary_protocol import ApplyUnitaryArgs, apply_unitaries
from cirq.protocols.decompose_protocol import _try_decompose_into_operations_and_qubits
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

# This is a special indicator value used by the unitary method to determine
# whether or not the caller provided a 'default' argument. It must be of type
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/sim/clifford/stabilizer_simulation_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from cirq.ops.clifford_gate import SingleQubitCliffordGate
from cirq.protocols import has_unitary, num_qubits, unitary
from cirq.sim.simulation_state import SimulationState
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/sim/simulation_state_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import numpy as np

from cirq import protocols, value
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType

if TYPE_CHECKING:
import cirq
Expand Down
2 changes: 1 addition & 1 deletion cirq-core/cirq/testing/consistent_protocols_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import cirq
from cirq._compat import proper_repr
from cirq.type_workarounds import NotImplementedType
from types import NotImplementedType
import cirq.testing.consistent_controlled_gate_op_test as controlled_gate_op_test


Expand Down
23 changes: 0 additions & 23 deletions cirq-core/cirq/type_workarounds.py

This file was deleted.

0 comments on commit 2f747de

Please sign in to comment.