Skip to content

Commit

Permalink
Fix python lint
Browse files Browse the repository at this point in the history
  • Loading branch information
arash77 committed Oct 7, 2024
1 parent da12168 commit 45feaa3
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/galaxy/webapps/galaxy/services/library_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import (
cast,
List,
Optional,
Tuple,
Union,
)
Expand Down Expand Up @@ -130,7 +131,7 @@ def create(
trans: ProvidesHistoryContext,
library_id: DecodedDatabaseIdField,
payload: AnyLibraryContentsCreatePayload,
files: List[StarletteUploadFile] = [],
files: Optional[List[StarletteUploadFile]] = None,
) -> AnyLibraryContentsCreateResponse:
"""Create a new library file or folder."""
if trans.user_is_bootstrap_admin:
Expand All @@ -157,13 +158,14 @@ def create(
if payload.create_type == "file":
payload = cast(LibraryContentsFileCreatePayload, payload)
upload_files = []
for upload_file in files:
with tempfile.NamedTemporaryFile(
dir=trans.app.config.new_file_path, prefix="upload_file_data_", delete=False
) as dest:
shutil.copyfileobj(upload_file.file, dest) # type: ignore[misc] # https://github.com/python/mypy/issues/15031
upload_file.file.close()
upload_files.append(dict(filename=upload_file.filename, local_filename=dest.name))
if files:
for upload_file in files:
with tempfile.NamedTemporaryFile(
dir=trans.app.config.new_file_path, prefix="upload_file_data_", delete=False
) as dest:
shutil.copyfileobj(upload_file.file, dest) # type: ignore[misc] # https://github.com/python/mypy/issues/15031
upload_file.file.close()
upload_files.append(dict(filename=upload_file.filename, local_filename=dest.name))
payload.upload_files = upload_files
rval = self._upload_library_dataset(trans, payload)
return LibraryContentsCreateFileListResponse(root=self._create_response(trans, payload, rval, library_id))
Expand Down

0 comments on commit 45feaa3

Please sign in to comment.