__init__.pyi 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. from typing import overload, Any, Tuple, Optional, Mapping, Union, Sequence, Type
  2. import multidict
  3. from functools import _CacheInfo
  4. import sys
  5. if sys.version_info >= (3, 8):
  6. from typing import TypedDict, Final, final
  7. else:
  8. from typing_extensions import TypedDict, Final, final
  9. _SimpleQuery = Union[str, int, float]
  10. _QueryVariable = Union[_SimpleQuery, Sequence[_SimpleQuery]]
  11. _Query = Union[
  12. None, str, Mapping[str, _QueryVariable], Sequence[Tuple[str, _QueryVariable]]
  13. ]
  14. @final
  15. class URL:
  16. scheme: Final[str]
  17. raw_user: Final[str]
  18. user: Final[Optional[str]]
  19. raw_password: Final[Optional[str]]
  20. password: Final[Optional[str]]
  21. raw_host: Final[Optional[str]]
  22. host: Final[Optional[str]]
  23. port: Final[Optional[int]]
  24. raw_authority: Final[str]
  25. authority: Final[str]
  26. raw_path: Final[str]
  27. path: Final[str]
  28. raw_query_string: Final[str]
  29. query_string: Final[str]
  30. path_qs: Final[str]
  31. raw_path_qs: Final[str]
  32. raw_fragment: Final[str]
  33. fragment: Final[str]
  34. query: Final[multidict.MultiDict[str]]
  35. raw_name: Final[str]
  36. name: Final[str]
  37. raw_parts: Final[Tuple[str, ...]]
  38. parts: Final[Tuple[str, ...]]
  39. parent: Final[URL]
  40. def __init__(
  41. self, val: Union[str, "URL"] = ..., *, encoded: bool = ...
  42. ) -> None: ...
  43. @classmethod
  44. def build(
  45. cls,
  46. *,
  47. scheme: str = ...,
  48. authority: str = ...,
  49. user: Optional[str] = ...,
  50. password: Optional[str] = ...,
  51. host: str = ...,
  52. port: Optional[int] = ...,
  53. path: str = ...,
  54. query: Optional[_Query] = ...,
  55. query_string: str = ...,
  56. fragment: str = ...,
  57. encoded: bool = ...
  58. ) -> URL: ...
  59. def __str__(self) -> str: ...
  60. def __repr__(self) -> str: ...
  61. def __eq__(self, other: Any) -> bool: ...
  62. def __le__(self, other: Any) -> bool: ...
  63. def __lt__(self, other: Any) -> bool: ...
  64. def __ge__(self, other: Any) -> bool: ...
  65. def __gt__(self, other: Any) -> bool: ...
  66. def __hash__(self) -> int: ...
  67. def __truediv__(self, name: str) -> URL: ...
  68. def __mod__(self, query: _Query) -> URL: ...
  69. def is_absolute(self) -> bool: ...
  70. def is_default_port(self) -> bool: ...
  71. def origin(self) -> URL: ...
  72. def relative(self) -> URL: ...
  73. def with_scheme(self, scheme: str) -> URL: ...
  74. def with_user(self, user: Optional[str]) -> URL: ...
  75. def with_password(self, password: Optional[str]) -> URL: ...
  76. def with_host(self, host: str) -> URL: ...
  77. def with_port(self, port: Optional[int]) -> URL: ...
  78. def with_path(self, path: str, *, encoded: bool = ...) -> URL: ...
  79. @overload
  80. def with_query(self, query: _Query) -> URL: ...
  81. @overload
  82. def with_query(self, **kwargs: _QueryVariable) -> URL: ...
  83. @overload
  84. def update_query(self, query: _Query) -> URL: ...
  85. @overload
  86. def update_query(self, **kwargs: _QueryVariable) -> URL: ...
  87. def with_fragment(self, fragment: Optional[str]) -> URL: ...
  88. def with_name(self, name: str) -> URL: ...
  89. def join(self, url: URL) -> URL: ...
  90. def human_repr(self) -> str: ...
  91. # private API
  92. @classmethod
  93. def _normalize_path(cls, path: str) -> str: ...
  94. @final
  95. class cached_property:
  96. def __init__(self, wrapped: Any) -> None: ...
  97. def __get__(self, inst: URL, owner: Type[URL]) -> Any: ...
  98. def __set__(self, inst: URL, value: Any) -> None: ...
  99. class CacheInfo(TypedDict):
  100. idna_encode: _CacheInfo
  101. idna_decode: _CacheInfo
  102. def cache_clear() -> None: ...
  103. def cache_info() -> CacheInfo: ...
  104. def cache_configure(
  105. *, idna_encode_size: Optional[int] = ..., idna_decode_size: Optional[int] = ...
  106. ) -> None: ...