Skip to content

Commit 8cc8643

Browse files
authored
remove circular import in t_counts_from_sigma (#933)
1 parent 6cd49f1 commit 8cc8643

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

qualtran/bloqs/util_bloqs_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
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+
import subprocess
1415
from functools import cached_property
1516
from typing import Dict, Type, Union
1617

@@ -290,3 +291,8 @@ def to_cirq_circuit(bloq: GateWithRegisters) -> cirq.Circuit:
290291
@pytest.mark.notebook
291292
def test_notebook():
292293
execute_notebook('util_bloqs')
294+
295+
296+
def test_no_circular_import():
297+
# There was a circular import that would only be triggered by this import incantation
298+
subprocess.check_call(['python', '-c', 'from qualtran.bloqs import util_bloqs'])

qualtran/resource_counting/t_counts_from_sigma.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,19 @@
1717

1818
import cirq
1919

20-
from qualtran.bloqs.basic_gates.rotation import _HasEps
2120
from qualtran.resource_counting.symbolic_counting_utils import ceil, SymbolicInt
2221

2322
if TYPE_CHECKING:
24-
import sympy
25-
2623
from qualtran import Bloq
24+
from qualtran.bloqs.basic_gates.rotation import _HasEps
2725

2826

29-
def _get_all_rotation_types() -> Tuple[Type[_HasEps], ...]:
27+
def _get_all_rotation_types() -> Tuple[Type['_HasEps'], ...]:
3028
"""Returns all classes defined in bloqs.basic_gates which have an attribute `eps`."""
31-
import qualtran.bloqs.basic_gates # pylint: disable=unused-import
29+
from qualtran.bloqs.basic_gates import GlobalPhase
30+
from qualtran.bloqs.basic_gates.rotation import _HasEps
3231

33-
bloqs_to_exclude = [qualtran.bloqs.basic_gates.GlobalPhase]
32+
bloqs_to_exclude = [GlobalPhase]
3433

3534
return tuple(
3635
v

0 commit comments

Comments
 (0)