mirror of
https://github.com/httpie/cli.git
synced 2025-02-16 17:40:51 +01:00
Simplify return statements in client.py (#1096)
Co-authored-by: Mickaël Schoentgen <contact@tiger-222.fr>
This commit is contained in:
parent
ae6f57dc76
commit
c8d70e8c0b
@ -213,11 +213,10 @@ def make_default_headers(args: argparse.Namespace) -> RequestHeadersDict:
|
|||||||
|
|
||||||
|
|
||||||
def make_send_kwargs(args: argparse.Namespace) -> dict:
|
def make_send_kwargs(args: argparse.Namespace) -> dict:
|
||||||
kwargs = {
|
return {
|
||||||
'timeout': args.timeout or None,
|
'timeout': args.timeout or None,
|
||||||
'allow_redirects': False,
|
'allow_redirects': False,
|
||||||
}
|
}
|
||||||
return kwargs
|
|
||||||
|
|
||||||
|
|
||||||
def make_send_kwargs_mergeable_from_env(args: argparse.Namespace) -> dict:
|
def make_send_kwargs_mergeable_from_env(args: argparse.Namespace) -> dict:
|
||||||
@ -226,7 +225,7 @@ def make_send_kwargs_mergeable_from_env(args: argparse.Namespace) -> dict:
|
|||||||
cert = args.cert
|
cert = args.cert
|
||||||
if args.cert_key:
|
if args.cert_key:
|
||||||
cert = cert, args.cert_key
|
cert = cert, args.cert_key
|
||||||
kwargs = {
|
return {
|
||||||
'proxies': {p.key: p.value for p in args.proxy},
|
'proxies': {p.key: p.value for p in args.proxy},
|
||||||
'stream': True,
|
'stream': True,
|
||||||
'verify': {
|
'verify': {
|
||||||
@ -237,7 +236,6 @@ def make_send_kwargs_mergeable_from_env(args: argparse.Namespace) -> dict:
|
|||||||
}.get(args.verify.lower(), args.verify),
|
}.get(args.verify.lower(), args.verify),
|
||||||
'cert': cert,
|
'cert': cert,
|
||||||
}
|
}
|
||||||
return kwargs
|
|
||||||
|
|
||||||
|
|
||||||
def make_request_kwargs(
|
def make_request_kwargs(
|
||||||
@ -279,7 +277,7 @@ def make_request_kwargs(
|
|||||||
content_type=args.headers.get('Content-Type'),
|
content_type=args.headers.get('Content-Type'),
|
||||||
)
|
)
|
||||||
|
|
||||||
kwargs = {
|
return {
|
||||||
'method': args.method.lower(),
|
'method': args.method.lower(),
|
||||||
'url': args.url,
|
'url': args.url,
|
||||||
'headers': headers,
|
'headers': headers,
|
||||||
@ -294,8 +292,6 @@ def make_request_kwargs(
|
|||||||
'params': args.params.items(),
|
'params': args.params.items(),
|
||||||
}
|
}
|
||||||
|
|
||||||
return kwargs
|
|
||||||
|
|
||||||
|
|
||||||
def ensure_path_as_is(orig_url: str, prepped_url: str) -> str:
|
def ensure_path_as_is(orig_url: str, prepped_url: str) -> str:
|
||||||
"""
|
"""
|
||||||
@ -320,5 +316,4 @@ def ensure_path_as_is(orig_url: str, prepped_url: str) -> str:
|
|||||||
**parsed_prepped._asdict(),
|
**parsed_prepped._asdict(),
|
||||||
'path': parsed_orig.path,
|
'path': parsed_orig.path,
|
||||||
}
|
}
|
||||||
final_url = urlunparse(tuple(final_dict.values()))
|
return urlunparse(tuple(final_dict.values()))
|
||||||
return final_url
|
|
||||||
|
Loading…
Reference in New Issue
Block a user