|
70 | 70 | Iterable[Tuple[Text, Optional[Text]]], |
71 | 71 | ] |
72 | 72 | T = TypeVar("T") |
| 73 | +# Literal is not available in all pythons so we only bring it in for mypy. |
| 74 | +if TYPE_CHECKING: |
| 75 | + from typing import Literal |
73 | 76 |
|
74 | 77 |
|
75 | 78 | # from boltons.typeutils |
@@ -2416,26 +2419,26 @@ def __dir__(self): |
2416 | 2419 |
|
2417 | 2420 | # # End Twisted Compat Code |
2418 | 2421 |
|
2419 | | -# Add some overloads so that parse gives a better return value. |
2420 | | -# Literal is not available in all pythons so we only bring it in for mypy. |
2421 | | -if TYPE_CHECKING: |
2422 | | - from typing import Literal |
2423 | 2422 |
|
| 2423 | +# Add some overloads so that parse gives a better return value. |
2424 | 2424 | @overload |
2425 | 2425 | def parse(url, decoded, lazy=False): |
2426 | 2426 | # type: (Text, Literal[False], bool) -> URL |
2427 | 2427 | """Passing decoded=False returns URL.""" |
2428 | 2428 |
|
| 2429 | + |
2429 | 2430 | @overload |
2430 | 2431 | def parse(url, decoded=True, lazy=False): |
2431 | 2432 | # type: (Text, Literal[True], bool) -> DecodedURL |
2432 | 2433 | """Passing decoded=True (or the default value) returns DecodedURL.""" |
2433 | 2434 |
|
| 2435 | + |
2434 | 2436 | @overload |
2435 | 2437 | def parse(url, decoded=True, lazy=False): |
2436 | 2438 | # type: (Text, bool, bool) -> Union[URL, DecodedURL] |
2437 | 2439 | """If decoded is not a literal we don't know the return type.""" |
2438 | 2440 |
|
| 2441 | + |
2439 | 2442 | def parse(url, decoded=True, lazy=False): |
2440 | 2443 | # type: (Text, bool, bool) -> Union[URL, DecodedURL] |
2441 | 2444 | """ |
|
0 commit comments