Skip to content

Commit d26a889

Browse files
authored
Improve pika (#13739)
1 parent 38a5859 commit d26a889

17 files changed

+438
-387
lines changed

stubs/pika/pika/__init__.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Final
2+
13
from pika import adapters as adapters
24
from pika.adapters import (
35
BaseConnection as BaseConnection,
@@ -9,3 +11,5 @@ from pika.connection import ConnectionParameters as ConnectionParameters, SSLOpt
911
from pika.credentials import PlainCredentials as PlainCredentials
1012
from pika.delivery_mode import DeliveryMode as DeliveryMode
1113
from pika.spec import BasicProperties as BasicProperties
14+
15+
__version__: Final[str]

stubs/pika/pika/adapters/asyncio_connection.pyi

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
from _typeshed import Incomplete
21
from asyncio import AbstractEventLoop
32
from collections.abc import Callable
43
from logging import Logger
54
from typing_extensions import Self
65

76
from ..connection import Parameters
87
from .base_connection import BaseConnection
9-
from .utils import io_services_utils, nbio_interface
8+
from .utils import connection_workflow, io_services_utils, nbio_interface
109

1110
LOGGER: Logger
1211

@@ -22,7 +21,11 @@ class AsyncioConnection(BaseConnection):
2221
) -> None: ...
2322
@classmethod
2423
def create_connection(
25-
cls, connection_configs, on_done, custom_ioloop: AbstractEventLoop | None = None, workflow: Incomplete | None = None
24+
cls,
25+
connection_configs,
26+
on_done,
27+
custom_ioloop: AbstractEventLoop | None = None,
28+
workflow: connection_workflow.AbstractAMQPConnectionWorkflow | None = None,
2629
): ...
2730

2831
class _AsyncioIOServicesAdapter(
@@ -31,7 +34,7 @@ class _AsyncioIOServicesAdapter(
3134
nbio_interface.AbstractIOServices,
3235
nbio_interface.AbstractFileDescriptorServices,
3336
):
34-
def __init__(self, loop: Incomplete | None = None) -> None: ...
37+
def __init__(self, loop: AbstractEventLoop | None = None) -> None: ...
3538
def get_native_ioloop(self): ...
3639
def close(self) -> None: ...
3740
def run(self) -> None: ...

stubs/pika/pika/adapters/base_connection.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import abc
22
from _typeshed import Incomplete
33
from collections.abc import Callable
4+
from logging import Logger
45
from typing_extensions import Self
56

67
from ..adapters.utils import nbio_interface
78
from ..connection import Connection
89

9-
LOGGER: Incomplete
10+
LOGGER: Logger
1011

1112
class BaseConnection(Connection, metaclass=abc.ABCMeta):
1213
def __init__(

stubs/pika/pika/adapters/blocking_connection.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from _typeshed import Incomplete, Unused
22
from collections.abc import Generator, Sequence
3+
from logging import Logger
34
from types import TracebackType
45
from typing import NamedTuple
56
from typing_extensions import Self
@@ -9,7 +10,7 @@ from ..data import _ArgumentMapping
910
from ..exchange_type import ExchangeType
1011
from ..spec import BasicProperties
1112

12-
LOGGER: Incomplete
13+
LOGGER: Logger
1314

1415
class _CallbackResult:
1516
def __init__(self, value_class: Incomplete | None = None) -> None: ...

stubs/pika/pika/adapters/gevent_connection.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from _typeshed import Incomplete
2+
from logging import Logger
23

34
from pika.adapters.base_connection import BaseConnection
45
from pika.adapters.utils.nbio_interface import AbstractIOReference
56
from pika.adapters.utils.selector_ioloop_adapter import AbstractSelectorIOLoop, SelectorIOServicesAdapter
67

7-
LOGGER: Incomplete
8+
LOGGER: Logger
89

910
class GeventConnection(BaseConnection):
1011
def __init__(

stubs/pika/pika/adapters/select_connection.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import abc
22
from _typeshed import Incomplete
3+
from logging import Logger
34

45
import pika.compat
56
from pika.adapters.base_connection import BaseConnection
67
from pika.adapters.utils.selector_ioloop_adapter import AbstractSelectorIOLoop
78

8-
LOGGER: Incomplete
9+
LOGGER: Logger
910
SELECT_TYPE: Incomplete
1011

1112
class SelectConnection(BaseConnection):

stubs/pika/pika/adapters/tornado_connection.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from _typeshed import Incomplete
2+
from logging import Logger
23

34
from pika.adapters import base_connection
45

5-
LOGGER: Incomplete
6+
LOGGER: Logger
67

78
class TornadoConnection(base_connection.BaseConnection):
89
def __init__(

stubs/pika/pika/adapters/twisted_connection.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# We don't want to force it as a dependency but that means we also can't test it with type-checkers given the current setup.
33

44
from _typeshed import Incomplete
5+
from logging import Logger
56
from typing import Generic, NamedTuple, TypeVar
67

78
import pika.connection
@@ -17,7 +18,7 @@ from twisted.python.failure import Failure # type: ignore[import-not-found] #
1718

1819
_T = TypeVar("_T")
1920

20-
LOGGER: Incomplete
21+
LOGGER: Logger
2122

2223
class ClosableDeferredQueue(DeferredQueue[_T], Generic[_T]): # pyright: ignore[reportUntypedBaseClass] # noqa: Y060
2324
closed: Failure | BaseException | None

stubs/pika/pika/adapters/utils/selector_ioloop_adapter.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import abc
22
from _typeshed import Incomplete
3+
from logging import Logger
34

45
from pika.adapters.utils import io_services_utils, nbio_interface
56

6-
LOGGER: Incomplete
7+
LOGGER: Logger
78

89
class AbstractSelectorIOLoop(metaclass=abc.ABCMeta):
910
@property

stubs/pika/pika/callback.pyi

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Callable
3+
from logging import Logger
4+
from typing import Literal
25

3-
LOGGER: Incomplete
6+
from pika import amqp_object, frame
47

5-
def name_or_value(value): ...
8+
LOGGER: Logger
9+
10+
def name_or_value(value: amqp_object.AMQPObject | frame.Frame | int | str) -> str: ...
611
def sanitize_prefix(function): ...
712
def check_for_prefix_and_key(function): ...
813

@@ -16,16 +21,22 @@ class CallbackManager:
1621
def __init__(self) -> None: ...
1722
def add(
1823
self,
19-
prefix,
20-
key,
21-
callback,
24+
prefix: str | int,
25+
key: str | object,
26+
callback: Callable[[Incomplete], Incomplete],
2227
one_shot: bool = True,
23-
only_caller: Incomplete | None = None,
28+
only_caller: object | None = None,
2429
arguments: Incomplete | None = None,
25-
): ...
30+
) -> tuple[str | int, str | object]: ...
2631
def clear(self) -> None: ...
27-
def cleanup(self, prefix): ...
28-
def pending(self, prefix, key): ...
29-
def process(self, prefix, key, caller, *args, **keywords): ...
30-
def remove(self, prefix, key, callback_value: Incomplete | None = None, arguments: Incomplete | None = None): ...
31-
def remove_all(self, prefix, key) -> None: ...
32+
def cleanup(self, prefix: str | int) -> bool: ...
33+
def pending(self, prefix: str | int, key: str | object) -> int | None: ...
34+
def process(self, prefix: str | int, key: str | object, caller, *args, **keywords) -> bool: ...
35+
def remove(
36+
self,
37+
prefix: str | int,
38+
key: str | object,
39+
callback_value: Callable[[Incomplete], Incomplete] | None = None,
40+
arguments: Incomplete | None = None,
41+
) -> Literal[True]: ...
42+
def remove_all(self, prefix: str | int, key: str | object) -> None: ...

0 commit comments

Comments
 (0)