|
1 | 1 | from typing import Any
|
| 2 | +from typing import Dict |
| 3 | +from typing import List |
2 | 4 | from typing import Mapping
|
| 5 | +from typing import NamedTuple |
3 | 6 | from typing import Optional
|
4 | 7 | from typing import Sequence
|
5 | 8 | from typing import Tuple
|
| 9 | +from typing import Type |
| 10 | +from typing import TypeVar |
6 | 11 | from typing import Union
|
7 | 12 |
|
8 |
| -from .interfaces import Dialect as Dialect |
9 |
| -from .. import exc as exc |
10 |
| -from .. import util as util |
11 |
| -from ..dialects import plugins as plugins |
12 |
| -from ..dialects import registry as registry |
13 |
| -from ..util import collections_abc as collections_abc |
14 |
| -from ..util import compat as compat |
| 13 | +from .interfaces import Dialect |
| 14 | +from .. import util |
15 | 15 |
|
16 |
| -class URL: |
17 |
| - def __new__(self, *arg: Any, **kw: Any): ... |
| 16 | +_TURL = TypeVar("_TURL", bound=URL) |
| 17 | + |
| 18 | +class URL(NamedTuple): |
| 19 | + drivername: str = ... |
| 20 | + username: Optional[str] = ... |
| 21 | + password: Optional[Union[str, object]] = ... |
| 22 | + host: Optional[str] = ... |
| 23 | + port: Optional[int] = ... |
| 24 | + database: Optional[str] = ... |
| 25 | + query: Mapping[str, Union[str, Sequence[str]]] = ... |
| 26 | + def __new__(self: Type[_TURL], *arg: Any, **kw: Any) -> _TURL: ... # type: ignore[misc] |
18 | 27 | @classmethod
|
19 | 28 | def create(
|
20 |
| - cls, |
| 29 | + cls: Type[_TURL], |
21 | 30 | drivername: str,
|
22 | 31 | username: Optional[str] = ...,
|
23 | 32 | password: Optional[Union[str, object]] = ...,
|
24 | 33 | host: Optional[str] = ...,
|
25 | 34 | port: Optional[int] = ...,
|
26 | 35 | database: Optional[str] = ...,
|
27 | 36 | query: Mapping[str, Union[str, Sequence[str]]] = ...,
|
28 |
| - ) -> URL: ... |
| 37 | + ) -> _TURL: ... |
29 | 38 | def set(
|
30 |
| - self, |
| 39 | + self: _TURL, |
31 | 40 | drivername: Optional[str] = ...,
|
32 | 41 | username: Optional[str] = ...,
|
33 | 42 | password: Optional[Union[str, object]] = ...,
|
34 | 43 | host: Optional[str] = ...,
|
35 | 44 | port: Optional[int] = ...,
|
36 | 45 | database: Optional[str] = ...,
|
37 | 46 | query: Optional[Mapping[str, Union[str, Sequence[str]]]] = ...,
|
38 |
| - ) -> URL: ... |
| 47 | + ) -> _TURL: ... |
39 | 48 | def update_query_string(
|
40 |
| - self, query_string: str, append: bool = ... |
41 |
| - ) -> URL: ... |
| 49 | + self: _TURL, query_string: str, append: bool = ... |
| 50 | + ) -> _TURL: ... |
42 | 51 | def update_query_pairs(
|
43 |
| - self, key_value_pairs: Sequence[Tuple[str, str]], append: bool = ... |
44 |
| - ) -> URL: ... |
| 52 | + self: _TURL, |
| 53 | + key_value_pairs: Sequence[Tuple[str, str]], |
| 54 | + append: bool = ..., |
| 55 | + ) -> _TURL: ... |
45 | 56 | def update_query_dict(
|
46 |
| - self, |
| 57 | + self: _TURL, |
47 | 58 | query_parameters: Mapping[str, Union[str, Sequence[str]]],
|
48 | 59 | append: bool = ...,
|
49 |
| - ) -> URL: ... |
50 |
| - def difference_update_query(self, names: Sequence[str]) -> URL: ... |
51 |
| - def normalized_query(self): ... |
| 60 | + ) -> _TURL: ... |
| 61 | + def difference_update_query( |
| 62 | + self: _TURL, names: Sequence[str] |
| 63 | + ) -> _TURL: ... |
| 64 | + @util.memoized_property |
| 65 | + def normalized_query(self) -> util.immutabledict[str, Any]: ... |
52 | 66 | def __to_string__(self, hide_password: bool = ...) -> str: ...
|
53 | 67 | def render_as_string(self, hide_password: bool = ...) -> str: ...
|
54 |
| - def __hash__(self) -> Any: ... |
55 |
| - def __eq__(self, other: Any) -> Any: ... |
56 |
| - def __ne__(self, other: Any) -> Any: ... |
57 |
| - def get_backend_name(self): ... |
58 |
| - def get_driver_name(self): ... |
59 |
| - def get_dialect(self): ... |
60 |
| - def translate_connect_args(self, names: Any = ..., **kw: Any): ... |
| 68 | + def __hash__(self) -> int: ... |
| 69 | + def __eq__(self, other: Any) -> bool: ... |
| 70 | + def __ne__(self, other: Any) -> bool: ... |
| 71 | + def get_backend_name(self) -> str: ... |
| 72 | + def get_driver_name(self) -> str: ... |
| 73 | + def get_dialect(self) -> Type[Dialect]: ... |
| 74 | + def translate_connect_args( |
| 75 | + self, names: List[str] = ..., **kw: Any |
| 76 | + ) -> Dict[str, Any]: ... |
61 | 77 |
|
62 | 78 | def make_url(name_or_url: Union[str, URL]) -> URL: ...
|
0 commit comments