Skip to content

Commit

Permalink
Change http method typehints to literal of methods
Browse files Browse the repository at this point in the history
  • Loading branch information
perklet committed Aug 2, 2024
1 parent 8691907 commit b8f2747
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions curl_cffi/requests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
from .headers import Headers, HeaderTypes
from .impersonate import BrowserType, BrowserTypeLiteral, ExtraFingerprints, ExtraFpDict
from .models import Request, Response
from .session import AsyncSession, ProxySpec, Session, ThreadType
from .session import AsyncSession, HttpMethod, ProxySpec, Session, ThreadType
from .websockets import WebSocket, WebSocketError, WsCloseCode


def request(
method: str,
method: HttpMethod,
url: str,
params: Optional[Union[Dict, List, Tuple]] = None,
data: Optional[Union[Dict[str, str], List[Tuple], str, BytesIO, bytes]] = None,
Expand Down
7 changes: 4 additions & 3 deletions curl_cffi/requests/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class BaseSessionParams(TypedDict, total=False):
BaseSessionParams = TypedDict

ThreadType = Literal["eventlet", "gevent"]
HttpMethod = Literal["GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "TRACE"]


def _is_absolute_url(url: str) -> bool:
Expand Down Expand Up @@ -346,7 +347,7 @@ def _set_extra_fp(self, curl, fp: ExtraFingerprints):
def _set_curl_options(
self,
curl,
method: str,
method: HttpMethod,
url: str,
params: Optional[Union[Dict, List, Tuple]] = None,
data: Optional[Union[Dict[str, str], List[Tuple], str, BytesIO, bytes]] = None,
Expand Down Expand Up @@ -888,7 +889,7 @@ def ws_connect(

def request(
self,
method: str,
method: HttpMethod,
url: str,
params: Optional[Union[Dict, List, Tuple]] = None,
data: Optional[Union[Dict[str, str], List[Tuple], str, BytesIO, bytes]] = None,
Expand Down Expand Up @@ -1180,7 +1181,7 @@ async def ws_connect(self, url, *args, **kwargs):

async def request(
self,
method: str,
method: HttpMethod,
url: str,
params: Optional[Union[Dict, List, Tuple]] = None,
data: Optional[Union[Dict[str, str], List[Tuple], str, BytesIO, bytes]] = None,
Expand Down

0 comments on commit b8f2747

Please sign in to comment.