mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-14 23:32:22 +08:00
Mark some urllib.parse return fields optional (#3332)
Per the urllib.parse documentation, username, password, hostname, and port will be set to None if not set in the parsed URL. The same is true for urlparse in Python 2 according to its documentation.
This commit is contained in:
committed by
Sebastian Rittau
parent
07c8675ba5
commit
f0ccb325aa
@@ -1,6 +1,6 @@
|
||||
# Stubs for urlparse (Python 2)
|
||||
|
||||
from typing import AnyStr, Dict, List, NamedTuple, Tuple, Sequence, Union, overload
|
||||
from typing import AnyStr, Dict, List, NamedTuple, Tuple, Sequence, Union, overload, Optional
|
||||
|
||||
_String = Union[str, unicode]
|
||||
|
||||
@@ -17,13 +17,13 @@ def clear_cache() -> None: ...
|
||||
|
||||
class ResultMixin(object):
|
||||
@property
|
||||
def username(self) -> str: ...
|
||||
def username(self) -> Optional[str]: ...
|
||||
@property
|
||||
def password(self) -> str: ...
|
||||
def password(self) -> Optional[str]: ...
|
||||
@property
|
||||
def hostname(self) -> str: ...
|
||||
def hostname(self) -> Optional[str]: ...
|
||||
@property
|
||||
def port(self) -> int: ...
|
||||
def port(self) -> Optional[int]: ...
|
||||
|
||||
class SplitResult(
|
||||
NamedTuple(
|
||||
|
||||
@@ -25,10 +25,10 @@ class _ResultMixinBytes(_ResultMixinBase[str]):
|
||||
|
||||
|
||||
class _NetlocResultMixinBase(Generic[AnyStr]):
|
||||
username: AnyStr
|
||||
password: AnyStr
|
||||
hostname: AnyStr
|
||||
port: int
|
||||
username: Optional[AnyStr]
|
||||
password: Optional[AnyStr]
|
||||
hostname: Optional[AnyStr]
|
||||
port: Optional[int]
|
||||
|
||||
class _NetlocResultMixinStr(_NetlocResultMixinBase[str], _ResultMixinStr): ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user