@@ -24,10 +24,9 @@ def nothing(data: str, /) -> str: ...
2424def nothing (data : "ReadableBuffer" , / , * , errors : str = "strict" ) -> bytes : ...
2525def nothing (data : "str | ReadableBuffer" , / , * , errors : str = "strict" ) -> str | bytes :
2626 """Transform a string or bytes-like object into nothing."""
27- as_string = isinstance (data , str )
28- data_bytes = data .encode ("utf-8" , errors ) if as_string else bytes (data )
27+ data_bytes = data .encode ("utf-8" , errors ) if isinstance (data , str ) else bytes (data )
2928 transformed = "" .join (format (byte , "08b" ) for byte in data_bytes ).translate ({48 : 0x200B , 49 : 0x200C })
30- return transformed if as_string else transformed .encode ("utf-8" , errors )
29+ return transformed if isinstance ( data , str ) else transformed .encode ("utf-8" , errors )
3130
3231
3332@overload
@@ -36,8 +35,7 @@ def something(data: str, /) -> str: ...
3635def something (data : "ReadableBuffer" , / , * , errors : str = "strict" ) -> bytes : ...
3736def something (data : "str | ReadableBuffer" , / , * , errors : str = "strict" ) -> str | bytes :
3837 """Transform nothing into a string or bytes-like object."""
39- as_string = isinstance (data , str )
40- data_str = data if as_string else bytes (data ).decode ("utf-8" , errors )
38+ data_str = data if isinstance (data , str ) else bytes (data ).decode ("utf-8" , errors )
4139 chars = bytearray ()
4240 bits = []
4341 for char in data_str :
@@ -50,7 +48,7 @@ def something(data: "str | ReadableBuffer", /, *, errors: str = "strict") -> str
5048 if len (bits ) == BYTE_SIZE :
5149 chars .append (int ("" .join (bits ), base = 2 ))
5250 bits .clear ()
53- return chars .decode ("utf-8" , errors ) if as_string else bytes (chars )
51+ return chars .decode ("utf-8" , errors ) if isinstance ( data , str ) else bytes (chars )
5452
5553
5654def encode (input : str , errors : str | None = None , / ) -> tuple [bytes , int ]:
0 commit comments