Skip to content

Commit

Permalink
Updates for 0.26.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanforbes committed Jul 25, 2022
1 parent bda37e2 commit ea06672
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
4 changes: 3 additions & 1 deletion asyncpg-stubs/connect_utils.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ _ParsedSSLType: TypeAlias = SSLContext | Literal[False]
_SSLType: TypeAlias = _ParsedSSLType | _SSLStringValues | bool
_HostType: TypeAlias = list[str] | str
_PortType: TypeAlias = list[int] | int
_PasswordType: TypeAlias = str | Callable[[], str] | Callable[[], Awaitable[str]]

PGPASSFILE: Final[str]

Expand All @@ -33,10 +34,11 @@ class SSLMode(IntEnum):

class _ConnectionParameters(NamedTuple):
user: str
password: str | Callable[[], str] | Callable[[], Awaitable[str]] | None
password: _PasswordType | None
database: str
ssl: _ParsedSSLType | None
sslmode: SSLMode | None
direct_tls: bool
connect_timeout: float
server_settings: dict[str, str] | None

Expand Down
12 changes: 6 additions & 6 deletions asyncpg-stubs/connection.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ _OutputType: TypeAlias = PathLike[Any] | BinaryIO | _Writer
_SourceType: TypeAlias = PathLike[Any] | BinaryIO | AsyncIterable[bytes]

_CopyFormat: TypeAlias = Literal['text', 'csv', 'binary']
_PasswordType: TypeAlias = (
str | Callable[[], str] | Callable[[], Coroutine[Any, Any, str]]
)

class _Listener(Protocol):
def __call__(
Expand Down Expand Up @@ -290,7 +287,7 @@ async def connect(
host: connect_utils._HostType | None = ...,
port: connect_utils._PortType | None = ...,
user: str | None = ...,
password: _PasswordType | None = ...,
password: connect_utils._PasswordType | None = ...,
passfile: str | None = ...,
database: str | None = ...,
loop: AbstractEventLoop | None = ...,
Expand All @@ -300,6 +297,7 @@ async def connect(
max_cacheable_statement_size: int = ...,
command_timeout: float | None = ...,
ssl: connect_utils._SSLType | None = ...,
direct_tls: bool = ...,
connection_class: type[Connection[_Record]] = ...,
record_class: type[_Record],
server_settings: dict[str, str] | None = ...,
Expand All @@ -311,7 +309,7 @@ async def connect( # pyright: ignore
host: connect_utils._HostType | None = ...,
port: connect_utils._PortType | None = ...,
user: str | None = ...,
password: _PasswordType | None = ...,
password: connect_utils._PasswordType | None = ...,
passfile: str | None = ...,
database: str | None = ...,
loop: AbstractEventLoop | None = ...,
Expand All @@ -321,6 +319,7 @@ async def connect( # pyright: ignore
max_cacheable_statement_size: int = ...,
command_timeout: float | None = ...,
ssl: connect_utils._SSLType | None = ...,
direct_tls: bool = ...,
connection_class: type[Connection[protocol.Record]] = ...,
record_class: type[protocol.Record] = ...,
server_settings: dict[str, str] | None = ...,
Expand All @@ -332,7 +331,7 @@ async def connect(
host: connect_utils._HostType | None = ...,
port: connect_utils._PortType | None = ...,
user: str | None = ...,
password: _PasswordType | None = ...,
password: connect_utils._PasswordType | None = ...,
passfile: str | None = ...,
database: str | None = ...,
loop: AbstractEventLoop | None = ...,
Expand All @@ -342,6 +341,7 @@ async def connect(
max_cacheable_statement_size: int = ...,
command_timeout: float | None = ...,
ssl: connect_utils._SSLType | None = ...,
direct_tls: bool = ...,
connection_class: type[_Connection],
record_class: type[_Record] = ...,
server_settings: dict[str, str] | None = ...,
Expand Down
36 changes: 31 additions & 5 deletions asyncpg-stubs/pool.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class Pool(Generic[_Record]):
host: connect_utils._HostType | None = ...,
port: connect_utils._PortType | None = ...,
user: str | None = ...,
password: connection._PasswordType | None = ...,
password: connect_utils._PasswordType | None = ...,
passfile: str | None = ...,
database: str | None = ...,
timeout: float = ...,
Expand All @@ -297,19 +297,45 @@ class Pool(Generic[_Record]):
async def executemany(
self, command: str, args: Any, *, timeout: float | None = ...
) -> None: ...
@overload
async def fetch(
self, query: str, *args: Any, timeout: float | None = ...
self,
query: str,
*args: Any,
timeout: float | None = ...,
record_class: None = ...,
) -> list[_Record]: ...
@overload
async def fetch(
self,
query: str,
*args: Any,
timeout: float | None = ...,
record_class: type[_OtherRecord],
) -> list[_OtherRecord]: ...
async def fetchval(
self,
query: str,
*args: Any,
column: int = ...,
timeout: float | None = ...,
) -> Any: ...
@overload
async def fetchrow(
self, query: str, *args: Any, timeout: float | None = ...
self,
query: str,
*args: Any,
timeout: float | None = ...,
record_class: None = ...,
) -> _Record | None: ...
@overload
async def fetchrow(
self,
query: str,
*args: Any,
timeout: float | None = ...,
record_class: type[_OtherRecord],
) -> _OtherRecord | None: ...
async def copy_from_table(
self,
table_name: str,
Expand Down Expand Up @@ -421,7 +447,7 @@ def create_pool(
host: connect_utils._HostType | None = ...,
port: connect_utils._PortType | None = ...,
user: str | None = ...,
password: connection._PasswordType | None = ...,
password: connect_utils._PasswordType | None = ...,
passfile: str | None = ...,
database: str | None = ...,
timeout: float = ...,
Expand All @@ -448,7 +474,7 @@ def create_pool(
host: connect_utils._HostType | None = ...,
port: connect_utils._PortType | None = ...,
user: str | None = ...,
password: connection._PasswordType | None = ...,
password: connect_utils._PasswordType | None = ...,
passfile: str | None = ...,
database: str | None = ...,
timeout: float = ...,
Expand Down

0 comments on commit ea06672

Please sign in to comment.