Skip to content

Commit 8824a5e

Browse files
authored
Workaround mypy bug by moving Sweepable into its own file (#388)
1 parent 6fdc34a commit 8824a5e

File tree

3 files changed

+28
-12
lines changed

3 files changed

+28
-12
lines changed

cirq/study/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
ParamResolver,
1919
)
2020
from cirq.study.study import (
21-
Sweepable,
2221
TrialResult,
2322
)
23+
from cirq.study.sweepable import (
24+
Sweepable,
25+
)
2426
from cirq.study.sweeps import (
2527
Points,
2628
Sweep,

cirq/study/study.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
"""Defines a study.
16-
"""
17-
18-
from typing import Iterable, Union
19-
20-
from cirq.study.resolver import ParamResolver
21-
from cirq.study.sweeps import Sweep
15+
"""Defines a study."""
2216

2317

2418
class TrialResultMeta(type):
@@ -49,7 +43,3 @@ class TrialResult(metaclass=TrialResultMeta):
4943
the first index running over the repetitions, and the second index
5044
running over the qubits for the corresponding measurements.
5145
"""
52-
53-
54-
Sweepable = Union[
55-
ParamResolver, Iterable[ParamResolver], Sweep, Iterable[Sweep]]

cirq/study/sweepable.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2018 The Cirq Developers
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Defines which types are Sweepable."""
16+
17+
from typing import Iterable, Union
18+
19+
from cirq.study.resolver import ParamResolver
20+
from cirq.study.sweeps import Sweep
21+
22+
23+
Sweepable = Union[
24+
ParamResolver, Iterable[ParamResolver], Sweep, Iterable[Sweep]]

0 commit comments

Comments
 (0)