]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Tiny refactor on _multipart.py & _main.py (#1971)
authorMohammadreza Jafari <30555691+fristhon@users.noreply.github.com>
Tue, 21 Dec 2021 17:15:34 +0000 (20:45 +0330)
committerGitHub <noreply@github.com>
Tue, 21 Dec 2021 17:15:34 +0000 (18:15 +0100)
* remove unnecessary casting in f-string

* merge nested condition

httpx/_main.py
httpx/_multipart.py

index 42426c7a71bd309338543f8b0985a4307c533dab..237875a0ae602862890e76d01cb7598f0daeb58b 100644 (file)
@@ -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)
index f05f02b4c5ab24c0643f710d583a741b0cac44d9..51ba556a776b57a8a37a4fe20f2f4f071ae28b5b 100644 (file)
@@ -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