refactor(requests): Make all the type hints dynamic

Made the code shorter by about ~500 lines and easier to maintain in return for making the arguments autocompletion bad for shells that don't check for dynamic type hints like IPython.
This commit is contained in:
Karim shoair
2025-11-23 20:48:51 +02:00
parent 2bae3261a0
commit 357b170e1c
3 changed files with 340 additions and 711 deletions
+13
View File
@@ -4,6 +4,8 @@ Type definitions for type checking purposes.
from typing import (
TYPE_CHECKING,
TypedDict,
TypeAlias,
cast,
overload,
Any,
@@ -34,6 +36,17 @@ PageLoadStates = Literal["commit", "domcontentloaded", "load", "networkidle"]
extraction_types = Literal["text", "html", "markdown"]
StrOrBytes = Union[str, bytes]
if TYPE_CHECKING: # pragma: no cover
from typing_extensions import Unpack
else: # pragma: no cover
class _Unpack:
@staticmethod
def __getitem__(*args, **kwargs):
pass
Unpack = _Unpack()
try:
# Python 3.11+