Skip to content

Commit

Permalink
[pika] Use protocol for _Credentials (#13159)
Browse files Browse the repository at this point in the history
  • Loading branch information
kbaikov authored Dec 2, 2024
1 parent a078e6f commit f7c6acd
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions stubs/pika/pika/credentials.pyi
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
from _typeshed import Incomplete
from logging import Logger
from typing import ClassVar
from typing_extensions import TypeAlias
from typing import ClassVar, Protocol

from .spec import Connection

# TODO: This could be turned into a protocol.
_Credentials: TypeAlias = Incomplete # noqa: Y047
class _Credentials(Protocol):
TYPE: ClassVar[str]
erase_on_connect: bool
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
def response_for(self, start: Connection.Start) -> tuple[str | None, bytes | None]: ...
def erase_credentials(self) -> None: ...

LOGGER: Logger

class PlainCredentials:
TYPE: ClassVar[str]
erase_on_connect: bool
username: str
password: str
erase_on_connect: bool
def __init__(self, username: str, password: str, erase_on_connect: bool = False) -> None: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
Expand All @@ -30,4 +33,4 @@ class ExternalCredentials:
def response_for(self, start: Connection.Start) -> tuple[str | None, bytes | None]: ...
def erase_credentials(self) -> None: ...

VALID_TYPES: Incomplete
VALID_TYPES: list[_Credentials]

0 comments on commit f7c6acd

Please sign in to comment.