From: Mohammadreza Jafari <30555691+fristhon@users.noreply.github.com> Date: Tue, 21 Dec 2021 17:15:34 +0000 (+0330) Subject: Tiny refactor on _multipart.py & _main.py (#1971) X-Git-Tag: 0.21.2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83c81aa9b8ef0f7825df413a673e6d9300065f3a;p=thirdparty%2Fhttpx.git Tiny refactor on _multipart.py & _main.py (#1971) * remove unnecessary casting in f-string * merge nested condition --- diff --git a/httpx/_main.py b/httpx/_main.py index 42426c7a..237875a0 100644 --- a/httpx/_main.py +++ b/httpx/_main.py @@ -487,7 +487,7 @@ def main( except RequestError as exc: console = rich.console.Console() - console.print(f"[red]{type(exc).__name__}[/red]: {str(exc)}") + console.print(f"[red]{type(exc).__name__}[/red]: {exc}") sys.exit(1) sys.exit(0 if response.is_success else 1) diff --git a/httpx/_multipart.py b/httpx/_multipart.py index f05f02b4..51ba556a 100644 --- a/httpx/_multipart.py +++ b/httpx/_multipart.py @@ -89,7 +89,7 @@ class FileField: fileobj = value content_type = guess_content_type(filename) - if isinstance(fileobj, str) or isinstance(fileobj, io.StringIO): + if isinstance(fileobj, (str, io.StringIO)): raise TypeError(f"Expected bytes or bytes-like object got: {type(fileobj)}") self.filename = filename