|
27 | 27 | import itertools |
28 | 28 | import math |
29 | 29 | from collections import defaultdict |
30 | | -from types import NotImplementedType |
31 | | -from typing import ( |
32 | | - AbstractSet, |
33 | | - Any, |
| 30 | +from collections.abc import ( |
34 | 31 | Callable, |
35 | | - cast, |
36 | 32 | Hashable, |
37 | 33 | Iterable, |
38 | 34 | Iterator, |
39 | 35 | Mapping, |
40 | 36 | MutableSequence, |
41 | | - overload, |
42 | | - Self, |
43 | 37 | Sequence, |
44 | | - TYPE_CHECKING, |
45 | | - TypeVar, |
46 | | - Union, |
| 38 | + Set, |
47 | 39 | ) |
| 40 | +from types import NotImplementedType |
| 41 | +from typing import Any, cast, overload, Self, TYPE_CHECKING, TypeVar, Union |
48 | 42 |
|
49 | 43 | import networkx |
50 | 44 | import numpy as np |
@@ -1341,7 +1335,7 @@ def _is_parameterized_(self) -> bool: |
1341 | 1335 | protocols.is_parameterized(tag) for tag in self.tags |
1342 | 1336 | ) |
1343 | 1337 |
|
1344 | | - def _parameter_names_(self) -> AbstractSet[str]: |
| 1338 | + def _parameter_names_(self) -> Set[str]: |
1345 | 1339 | op_params = {name for op in self.all_operations() for name in protocols.parameter_names(op)} |
1346 | 1340 | tag_params = {name for tag in self.tags for name in protocols.parameter_names(tag)} |
1347 | 1341 | return op_params | tag_params |
@@ -1845,7 +1839,7 @@ def __init__( |
1845 | 1839 | self._frozen: cirq.FrozenCircuit | None = None |
1846 | 1840 | self._is_measurement: bool | None = None |
1847 | 1841 | self._is_parameterized: bool | None = None |
1848 | | - self._parameter_names: AbstractSet[str] | None = None |
| 1842 | + self._parameter_names: Set[str] | None = None |
1849 | 1843 | if not contents: |
1850 | 1844 | return |
1851 | 1845 | flattened_contents = tuple(ops.flatten_to_ops_or_moments(contents)) |
@@ -1954,7 +1948,7 @@ def _is_parameterized_(self) -> bool: |
1954 | 1948 | self._is_parameterized = super()._is_parameterized_() |
1955 | 1949 | return self._is_parameterized |
1956 | 1950 |
|
1957 | | - def _parameter_names_(self) -> AbstractSet[str]: |
| 1951 | + def _parameter_names_(self) -> Set[str]: |
1958 | 1952 | if self._parameter_names is None: |
1959 | 1953 | self._parameter_names = super()._parameter_names_() |
1960 | 1954 | return self._parameter_names |
|
0 commit comments