Skip to content

Commit 855ece5

Browse files
authored
Merge pull request #25 from ionq/churchill/fix-pdoc-submodule-discovery
Add __all__ to hand-written modules; simplify __init__.py template
2 parents da7dcb3 + ccde35c commit 855ece5

9 files changed

Lines changed: 70 additions & 117 deletions

File tree

Lines changed: 14 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,17 @@
11
{% from "helpers.jinja" import safe_docstring %}
2+
{% set modules = ["exceptions", "extensions", "gates", "ionq_client", "pagination", "polling", "session"] %}
23
{{ safe_docstring(package_description) }}
3-
from .exceptions import (
4-
APIConnectionError,
5-
APIError,
6-
APITimeoutError,
7-
AuthenticationError,
8-
BadRequestError,
9-
IonQError,
10-
NotFoundError,
11-
PermissionDeniedError,
12-
RateLimitError,
13-
ServerError,
14-
)
15-
from .extensions import AsyncEventHook, ClientExtension, EventHook
16-
from .gates import gpi2_matrix, gpi_matrix, ms_matrix, zz_matrix
17-
from .pagination import aiter_jobs, aiter_session_jobs, iter_jobs, iter_session_jobs
18-
from .polling import (
19-
JobFailedError,
20-
JobTimeoutError,
21-
async_wait_for_job,
22-
wait_for_job,
23-
)
24-
from .session import SessionManager
25-
from .client import AuthenticatedClient, Client
26-
from .ionq_client import IonQClient, __version__
27-
from .types import UNSET, Unset
4+
from . import {{ modules | join(", ") }}
5+
from .client import AuthenticatedClient, Client # noqa: F401
6+
{% for m in modules %}
7+
from .{{ m }} import * # noqa: F403
8+
{% endfor %}
9+
from .types import UNSET, Unset # noqa: F401
2810

29-
__all__ = (
30-
"UNSET",
31-
"APIConnectionError",
32-
"APIError",
33-
"APITimeoutError",
34-
"AsyncEventHook",
35-
"AuthenticatedClient",
36-
"AuthenticationError",
37-
"BadRequestError",
38-
"Client",
39-
"ClientExtension",
40-
"EventHook",
41-
"IonQClient",
42-
"IonQError",
43-
"JobFailedError",
44-
"JobTimeoutError",
45-
"NotFoundError",
46-
"PermissionDeniedError",
47-
"RateLimitError",
48-
"ServerError",
49-
"SessionManager",
50-
"Unset",
51-
"__version__",
52-
"aiter_jobs",
53-
"aiter_session_jobs",
54-
"async_wait_for_job",
55-
"gpi2_matrix",
56-
"gpi_matrix",
57-
"iter_jobs",
58-
"iter_session_jobs",
59-
"ms_matrix",
60-
"wait_for_job",
61-
"zz_matrix",
62-
)
11+
__all__ = sorted({
12+
{{ modules | map("tojson") | join(", ") }},
13+
"AuthenticatedClient", "Client", "UNSET", "Unset",
14+
{% for m in modules %}
15+
*{{ m }}.__all__,
16+
{% endfor %}
17+
})

ionq_core/__init__.py

Lines changed: 31 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,36 @@
33

44
"""A client library for accessing IonQ Cloud Platform API"""
55

6-
from .client import AuthenticatedClient, Client
7-
from .exceptions import (
8-
APIConnectionError,
9-
APIError,
10-
APITimeoutError,
11-
AuthenticationError,
12-
BadRequestError,
13-
IonQError,
14-
NotFoundError,
15-
PermissionDeniedError,
16-
RateLimitError,
17-
ServerError,
18-
)
19-
from .extensions import AsyncEventHook, ClientExtension, EventHook
20-
from .gates import gpi2_matrix, gpi_matrix, ms_matrix, zz_matrix
21-
from .ionq_client import IonQClient, __version__
22-
from .pagination import aiter_jobs, aiter_session_jobs, iter_jobs, iter_session_jobs
23-
from .polling import (
24-
JobFailedError,
25-
JobTimeoutError,
26-
async_wait_for_job,
27-
wait_for_job,
28-
)
29-
from .session import SessionManager
30-
from .types import UNSET, Unset
6+
from . import exceptions, extensions, gates, ionq_client, pagination, polling, session
7+
from .client import AuthenticatedClient, Client # noqa: F401
8+
from .exceptions import * # noqa: F403
9+
from .extensions import * # noqa: F403
10+
from .gates import * # noqa: F403
11+
from .ionq_client import * # noqa: F403
12+
from .pagination import * # noqa: F403
13+
from .polling import * # noqa: F403
14+
from .session import * # noqa: F403
15+
from .types import UNSET, Unset # noqa: F401
3116

32-
__all__ = (
33-
"UNSET",
34-
"APIConnectionError",
35-
"APIError",
36-
"APITimeoutError",
37-
"AsyncEventHook",
38-
"AuthenticatedClient",
39-
"AuthenticationError",
40-
"BadRequestError",
41-
"Client",
42-
"ClientExtension",
43-
"EventHook",
44-
"IonQClient",
45-
"IonQError",
46-
"JobFailedError",
47-
"JobTimeoutError",
48-
"NotFoundError",
49-
"PermissionDeniedError",
50-
"RateLimitError",
51-
"ServerError",
52-
"SessionManager",
53-
"Unset",
54-
"__version__",
55-
"aiter_jobs",
56-
"aiter_session_jobs",
57-
"async_wait_for_job",
58-
"gpi2_matrix",
59-
"gpi_matrix",
60-
"iter_jobs",
61-
"iter_session_jobs",
62-
"ms_matrix",
63-
"wait_for_job",
64-
"zz_matrix",
17+
__all__ = sorted(
18+
{
19+
"exceptions",
20+
"extensions",
21+
"gates",
22+
"ionq_client",
23+
"pagination",
24+
"polling",
25+
"session",
26+
"AuthenticatedClient",
27+
"Client",
28+
"UNSET",
29+
"Unset",
30+
*exceptions.__all__,
31+
*extensions.__all__,
32+
*gates.__all__,
33+
*ionq_client.__all__,
34+
*pagination.__all__,
35+
*polling.__all__,
36+
*session.__all__,
37+
}
6538
)

ionq_core/exceptions.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@
3232
```
3333
"""
3434

35+
__all__ = [
36+
"APIConnectionError",
37+
"APIError",
38+
"APITimeoutError",
39+
"AuthenticationError",
40+
"BadRequestError",
41+
"IonQError",
42+
"NotFoundError",
43+
"PermissionDeniedError",
44+
"RateLimitError",
45+
"ServerError",
46+
]
47+
3548

3649
class IonQError(Exception):
3750
"""Base exception for all IonQ errors.

ionq_core/extensions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def on_response(self, request: httpx.Request, response: httpx.Response) -> None:
3131
```
3232
"""
3333

34+
__all__ = ["AsyncEventHook", "ClientExtension", "EventHook"]
35+
3436
import logging
3537
from collections.abc import Callable
3638
from typing import Protocol, runtime_checkable

ionq_core/gates.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
```
2929
"""
3030

31+
__all__ = ["gpi2_matrix", "gpi_matrix", "ms_matrix", "zz_matrix"]
32+
3133
import cmath
3234
import math
3335

ionq_core/ionq_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
async httpx transports.
1010
"""
1111

12+
__all__ = ["IonQClient", "__version__"]
13+
1214
import os
1315
import platform
1416
import warnings

ionq_core/pagination.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
from __future__ import annotations
2121

22+
__all__ = ["aiter_jobs", "aiter_session_jobs", "iter_jobs", "iter_session_jobs"]
23+
2224
import logging
2325
from collections.abc import AsyncIterator, Callable, Iterator
2426
from typing import TYPE_CHECKING, Any

ionq_core/polling.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
from __future__ import annotations
2424

25+
__all__ = ["JobFailedError", "JobTimeoutError", "async_wait_for_job", "wait_for_job"]
26+
2527
import asyncio
2628
import logging
2729
import time

ionq_core/session.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
from __future__ import annotations
2929

30+
__all__ = ["SessionManager"]
31+
3032
import logging
3133
from typing import TYPE_CHECKING
3234

0 commit comments

Comments
 (0)