|
43 | 43 | TypeVar, |
44 | 44 | Union, |
45 | 45 | cast, |
| 46 | + TYPE_CHECKING, |
46 | 47 | ) |
47 | 48 | from unicodedata import normalize |
48 | 49 | from ._socket import inet_pton |
|
65 | 66 | QueryParameters = Union[ |
66 | 67 | Mapping[Text, Optional[Text]], |
67 | 68 | QueryPairs, |
68 | | - Sequence[Tuple[Text, Optional[Text]]], |
| 69 | + Iterable[Tuple[Text, Optional[Text]]], |
69 | 70 | ] |
70 | 71 | T = TypeVar("T") |
71 | 72 |
|
@@ -2415,6 +2416,35 @@ def __dir__(self): |
2415 | 2416 | # # End Twisted Compat Code |
2416 | 2417 |
|
2417 | 2418 |
|
| 2419 | +if TYPE_CHECKING: |
| 2420 | + # Add some overloads so that parse gives a better return value. |
| 2421 | + # Literal is not available in all pythons so we only bring it in for mypy. |
| 2422 | + # Also to remain compatible with 2.7 we use pass instead of ... |
| 2423 | + from typing import Literal, overload |
| 2424 | + |
| 2425 | + @overload |
| 2426 | + def parse(url): |
| 2427 | + # type: (Text) -> DecodedURL |
| 2428 | + pass |
| 2429 | + |
| 2430 | + |
| 2431 | + @overload |
| 2432 | + def parse(url, decoded, lazy=False): |
| 2433 | + # type: (Text, Literal[True], bool) -> DecodedURL |
| 2434 | + pass |
| 2435 | + |
| 2436 | + |
| 2437 | + @overload |
| 2438 | + def parse(url, decoded, lazy=False): |
| 2439 | + # type: (Text, Literal[False], bool) -> URL |
| 2440 | + pass |
| 2441 | + |
| 2442 | + @overload |
| 2443 | + def parse(url, decoded=True, lazy=False): |
| 2444 | + # type: (Text, bool, bool) -> Union[URL, DecodedURL] |
| 2445 | + pass |
| 2446 | + |
| 2447 | + |
2418 | 2448 | def parse(url, decoded=True, lazy=False): |
2419 | 2449 | # type: (Text, bool, bool) -> Union[URL, DecodedURL] |
2420 | 2450 | """ |
|
0 commit comments