apply autoformat

development
mattsb42-aws 2018-11-02 13:14:40 -07:00
parent 3105277cfe
commit 63a267f628
4 changed files with 9 additions and 8 deletions

View File

@ -1,9 +1,9 @@
# pylint: disable=invalid-name # pylint: disable=invalid-name
"""Sphinx configuration.""" """Sphinx configuration."""
from datetime import datetime
import io import io
import os import os
import re import re
from datetime import datetime
VERSION_RE = re.compile(r"""__version__ = ['"]([0-9.]+)['"]""") VERSION_RE = re.compile(r"""__version__ = ['"]([0-9.]+)['"]""")
HERE = os.path.abspath(os.path.dirname(__file__)) HERE = os.path.abspath(os.path.dirname(__file__))

View File

@ -227,7 +227,7 @@ class Base64IO(io.IOBase):
return data return data
_data_buffer = io.BytesIO() if isinstance(data, bytes) else io.StringIO() _data_buffer = io.BytesIO() if isinstance(data, bytes) else io.StringIO()
join_char = b'' if isinstance(data, bytes) else u'' join_char = b"" if isinstance(data, bytes) else u""
_data_buffer.write(join_char.join(data.split())) # type: ignore _data_buffer.write(join_char.join(data.split())) # type: ignore
_remaining_bytes_to_read = total_bytes_to_read - _data_buffer.tell() # type: ignore _remaining_bytes_to_read = total_bytes_to_read - _data_buffer.tell() # type: ignore
@ -274,8 +274,9 @@ class Base64IO(io.IOBase):
data = self.__wrapped.read(_bytes_to_read) data = self.__wrapped.read(_bytes_to_read)
# Remove whitespace from read data and attempt to read more data to get the desired # Remove whitespace from read data and attempt to read more data to get the desired
# number of bytes. # number of bytes.
whitespace = string.whitespace.encode("utf-8") if isinstance(data, bytes) \ whitespace = (
else string.whitespace # type: Union[bytes, str] string.whitespace.encode("utf-8") if isinstance(data, bytes) else string.whitespace
) # type: Union[bytes, str]
if any([char in data for char in whitespace]): if any([char in data for char in whitespace]):
data = self._read_additional_data_removing_whitespace(data, _bytes_to_read) data = self._read_additional_data_removing_whitespace(data, _bytes_to_read)

View File

@ -19,8 +19,8 @@ import io
import math import math
import os import os
from mock import MagicMock, sentinel
import pytest import pytest
from mock import MagicMock, sentinel
from base64io import Base64IO from base64io import Base64IO
@ -159,7 +159,7 @@ def test_base64io_decode(bytes_to_generate, bytes_per_round, number_of_rounds, t
) )
def test_base64io_decode_str(bytes_to_generate, bytes_per_round, number_of_rounds, total_bytes_to_expect): def test_base64io_decode_str(bytes_to_generate, bytes_per_round, number_of_rounds, total_bytes_to_expect):
plaintext_source = os.urandom(bytes_to_generate) plaintext_source = os.urandom(bytes_to_generate)
plaintext_b64 = io.StringIO(base64.b64encode(plaintext_source).decode('ascii')) plaintext_b64 = io.StringIO(base64.b64encode(plaintext_source).decode("ascii"))
plaintext_wrapped = Base64IO(plaintext_b64) plaintext_wrapped = Base64IO(plaintext_b64)
test = b"" test = b""
@ -315,7 +315,7 @@ def test_base64io_decode_with_whitespace(plaintext_source, b64_plaintext_with_wh
@pytest.mark.parametrize("plaintext_source, b64_plaintext_with_whitespace, read_bytes", build_whitespace_testcases()) @pytest.mark.parametrize("plaintext_source, b64_plaintext_with_whitespace, read_bytes", build_whitespace_testcases())
def test_base64io_decode_with_whitespace_str(plaintext_source, b64_plaintext_with_whitespace, read_bytes): def test_base64io_decode_with_whitespace_str(plaintext_source, b64_plaintext_with_whitespace, read_bytes):
with Base64IO(io.StringIO(b64_plaintext_with_whitespace.decode('ascii'))) as decoder: with Base64IO(io.StringIO(b64_plaintext_with_whitespace.decode("ascii"))) as decoder:
test = decoder.read(read_bytes) test = decoder.read(read_bytes)
assert test == plaintext_source[:read_bytes] assert test == plaintext_source[:read_bytes]

View File

@ -32,7 +32,7 @@ def test_file():
if is_python2: if is_python2:
# If we are in Python 2, the "file" assignment should not # If we are in Python 2, the "file" assignment should not
# happen because it is a builtin object. # happen because it is a builtin object.
assert not hasattr(base64io, 'file') assert not hasattr(base64io, "file")
else: else:
# If we are in Python 3, the "file" assignment should happen # If we are in Python 3, the "file" assignment should happen
# to provide a concrete definition of the "file" name. # to provide a concrete definition of the "file" name.