Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support patch method #72

Merged
merged 1 commit into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions aio_request/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Method:
POST = "POST"
PUT = "PUT"
DELETE = "DELETE"
PATCH = "PATCH"


class Header:
Expand Down
42 changes: 42 additions & 0 deletions aio_request/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,24 @@ def put(
)


def patch(
url: Union[str, yarl.URL],
body: Optional[bytes] = None,
*,
headers: Optional[Headers] = None,
path_parameters: Optional[PathParameters] = None,
query_parameters: Optional[QueryParameters] = None,
) -> Request:
return build_request(
Method.PATCH,
url,
path_parameters=path_parameters,
query_parameters=query_parameters,
headers=headers,
body=body,
)


def delete(
url: Union[str, yarl.URL],
*,
Expand Down Expand Up @@ -109,6 +127,30 @@ def put_json(
)


def patch_json(
url: Union[str, yarl.URL],
data: Any,
*,
path_parameters: Optional[PathParameters] = None,
query_parameters: Optional[QueryParameters] = None,
headers: Optional[Headers] = None,
encoding: str = "utf-8",
dumps: Callable[[str], Any] = json.dumps,
content_type: str = "application/json",
) -> Request:
return build_json_request(
Method.PATCH,
url,
data,
path_parameters=path_parameters,
query_parameters=query_parameters,
headers=headers,
encoding=encoding,
dumps=dumps,
content_type=content_type,
)


def build_json_request(
method: str,
url: Union[str, yarl.URL],
Expand Down
1 change: 1 addition & 0 deletions aio_request/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def setup_v2(
Method.POST: unsafe_method_strategy,
Method.PUT: unsafe_method_strategy,
Method.DELETE: unsafe_method_strategy,
Method.PATCH: unsafe_method_strategy,
}
)
return DefaultClient(
Expand Down