Skip to content
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

Update API.md #1468

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update API.md #1468

wants to merge 1 commit into from

Conversation

counter2015
Copy link

The goal of this PR is to optimize the examples in the documentation. The original examples in the documentation triggered warnings in the IDE which says "Local variable 'response' might be referenced before assignment ". The revised version is consistent with the actual usage in the source code.

minio-py/minio/api.py

Lines 1133 to 1161 in a7b443d

response = None
try:
response = self.get_object(
bucket_name,
object_name,
request_headers=request_headers,
ssec=ssec,
version_id=version_id,
extra_query_params=extra_query_params,
)
if progress:
# Set progress bar length and object name before upload
length = int(response.headers.get('content-length', 0))
progress.set_meta(object_name=object_name, total_length=length)
with open(tmp_file_path, "wb") as tmp_file:
for data in response.stream(amt=1024 * 1024):
size = tmp_file.write(data)
if progress:
progress.update(size)
if os.path.exists(file_path):
os.remove(file_path) # For windows compatibility.
os.rename(tmp_file_path, file_path)
return stat
finally:
if response:
response.close()
response.release_conn()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants