Skip to content

Commit

Permalink
Lint with black
Browse files Browse the repository at this point in the history
  • Loading branch information
Israel Brewster committed Jul 9, 2024
1 parent 2d1ecf3 commit 450cb2c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions streaming_form_data/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@ def on_data_received(self, chunk: bytes):
def value(self):
return b"".join(self._values)


class ListTarget(BaseTarget):
"""ValueTarget stores the input in an in-memory list of bytes.
This is useful in case you'd like to have the value contained in an
in-memory string.
"""

def __init__(self, _type = bytes, *args, **kwargs):
def __init__(self, _type=bytes, *args, **kwargs):
super().__init__(*args, **kwargs)

self._temp_value = []
Expand All @@ -100,11 +101,11 @@ def on_data_received(self, chunk: bytes):
self._temp_value.append(chunk)

def on_finish(self):
value = b''.join(self._temp_value)
value = b"".join(self._temp_value)
self._temp_value = []

if self._type == str:
value = value.decode('UTF-8')
value = value.decode("UTF-8")
elif self._type == bytes:
pass # already is bytes, no need to do anything
else:
Expand Down
6 changes: 4 additions & 2 deletions tests/test_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,16 @@ def test_list_target_basic():
target.finish()

assert target.multipart_filename is None
assert target.value == [b"Cat",b"Dog",b"Fish"]
assert target.value == [b"Cat", b"Dog", b"Fish"]


def test_list_target_not_set():
target=ListTarget()
target = ListTarget()

assert target.multipart_filename is None
assert target.value == []


def test_file_target_basic():
filename = os.path.join(tempfile.gettempdir(), "file.txt")

Expand Down

0 comments on commit 450cb2c

Please sign in to comment.