forked from adafruit/Adafruit_CircuitPython_Requests
-
Notifications
You must be signed in to change notification settings - Fork 0
Remove str concatenation #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
FoamyGuy
merged 1 commit into
FoamyGuy:files_arg
from
justmobilize:files_arg_no_str_concat
May 4, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -369,22 +369,22 @@ def _build_boundary_data(self, files: dict): # pylint: disable=too-many-locals | |
file_name = field_values[0] | ||
file_handle = field_values[1] | ||
|
||
boundary_data = f"--{boundary_string}\r\n" | ||
boundary_data += f'Content-Disposition: form-data; name="{field_name}"' | ||
boundary_objects.append( | ||
f'--{boundary_string}\r\nContent-Disposition: form-data; name="{field_name}"' | ||
) | ||
if file_name is not None: | ||
boundary_data += f'; filename="{file_name}"' | ||
boundary_data += "\r\n" | ||
boundary_objects.append(f'; filename="{file_name}"') | ||
boundary_objects.append("\r\n") | ||
if len(field_values) >= 3: | ||
file_content_type = field_values[2] | ||
boundary_data += f"Content-Type: {file_content_type}\r\n" | ||
boundary_objects.append(f"Content-Type: {file_content_type}\r\n") | ||
if len(field_values) >= 4: | ||
file_headers = field_values[3] | ||
for file_header_key, file_header_value in file_headers.items(): | ||
boundary_data += f"{file_header_key}: {file_header_value}\r\n" | ||
boundary_data += "\r\n" | ||
|
||
content_length += len(boundary_data) | ||
boundary_objects.append(boundary_data) | ||
boundary_objects.append( | ||
f"{file_header_key}: {file_header_value}\r\n" | ||
) | ||
boundary_objects.append("\r\n") | ||
|
||
if hasattr(file_handle, "read"): | ||
is_binary = False | ||
|
@@ -400,19 +400,15 @@ def _build_boundary_data(self, files: dict): # pylint: disable=too-many-locals | |
file_handle.seek(0, SEEK_END) | ||
content_length += file_handle.tell() | ||
file_handle.seek(0) | ||
boundary_objects.append(file_handle) | ||
boundary_data = "" | ||
else: | ||
boundary_data = file_handle | ||
|
||
boundary_data += "\r\n" | ||
content_length += len(boundary_data) | ||
boundary_objects.append(boundary_data) | ||
boundary_objects.append(file_handle) | ||
boundary_objects.append("\r\n") | ||
|
||
boundary_data = f"--{boundary_string}--\r\n" | ||
boundary_objects.append(f"--{boundary_string}--\r\n") | ||
|
||
content_length += len(boundary_data) | ||
boundary_objects.append(boundary_data) | ||
for boundary_object in boundary_objects: | ||
if isinstance(boundary_object, str): | ||
content_length += len(boundary_object) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and calculate the length at the end |
||
|
||
return boundary_string, content_length, boundary_objects | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,13 +10,15 @@ envlist = py311 | |
description = run tests | ||
deps = | ||
pytest==7.4.3 | ||
requests | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. needed to run tox, since requests is now in optional |
||
commands = pytest | ||
|
||
[testenv:coverage] | ||
description = run coverage | ||
deps = | ||
pytest==7.4.3 | ||
pytest-cov==4.1.0 | ||
requests | ||
package = editable | ||
commands = | ||
coverage run --source=. --omit=tests/* --branch {posargs} -m pytest | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add all strings to the list