mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 09:21:13 +08:00
Add more ruff rules (#8767)
* Add more ruff rules * Add more ruff rules * pre-commit: Update ruff v0.0.269 -> v0.0.270 * Apply suggestions from code review * Fix doctest * Fix doctest (ignore whitespace) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -34,9 +34,8 @@ def base64_encode(data: bytes) -> bytes:
|
||||
"""
|
||||
# Make sure the supplied data is a bytes-like object
|
||||
if not isinstance(data, bytes):
|
||||
raise TypeError(
|
||||
f"a bytes-like object is required, not '{data.__class__.__name__}'"
|
||||
)
|
||||
msg = f"a bytes-like object is required, not '{data.__class__.__name__}'"
|
||||
raise TypeError(msg)
|
||||
|
||||
binary_stream = "".join(bin(byte)[2:].zfill(8) for byte in data)
|
||||
|
||||
@ -88,10 +87,11 @@ def base64_decode(encoded_data: str) -> bytes:
|
||||
"""
|
||||
# Make sure encoded_data is either a string or a bytes-like object
|
||||
if not isinstance(encoded_data, bytes) and not isinstance(encoded_data, str):
|
||||
raise TypeError(
|
||||
"argument should be a bytes-like object or ASCII string, not "
|
||||
f"'{encoded_data.__class__.__name__}'"
|
||||
msg = (
|
||||
"argument should be a bytes-like object or ASCII string, "
|
||||
f"not '{encoded_data.__class__.__name__}'"
|
||||
)
|
||||
raise TypeError(msg)
|
||||
|
||||
# In case encoded_data is a bytes-like object, make sure it contains only
|
||||
# ASCII characters so we convert it to a string object
|
||||
|
Reference in New Issue
Block a user