-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: Add option to modify how a query is printed #54
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -68,6 +68,7 @@ def __init__( | |||||
self.keep_local = keep_local | ||||||
self.retrieve = retrieve | ||||||
self.provider = provider | ||||||
self.print_query = self.provider.safe_print(self.query) | ||||||
self._overwrite_local_path = None | ||||||
self.__post_init__() | ||||||
|
||||||
|
@@ -143,21 +144,21 @@ async def managed_size(self) -> int: | |||||
async with self._rate_limiter(Operation.SIZE): | ||||||
return self.size() | ||||||
except Exception as e: | ||||||
raise WorkflowError(f"Failed to get size of {self.query}", e) | ||||||
raise WorkflowError(f"Failed to get size of {self.print_query}", e) | ||||||
|
||||||
async def managed_mtime(self) -> float: | ||||||
try: | ||||||
async with self._rate_limiter(Operation.MTIME): | ||||||
return self.mtime() | ||||||
except Exception as e: | ||||||
raise WorkflowError(f"Failed to get mtime of {self.query}", e) | ||||||
raise WorkflowError(f"Failed to get mtime of {self.print_query}", e) | ||||||
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. Use The change from To improve the clarity of the exception, use - raise WorkflowError(f"Failed to get mtime of {self.print_query}", e)
+ raise WorkflowError(f"Failed to get mtime of {self.print_query}") from e Committable suggestion
Suggested change
ToolsRuff
|
||||||
|
||||||
async def managed_exists(self) -> bool: | ||||||
try: | ||||||
async with self._rate_limiter(Operation.EXISTS): | ||||||
return self.exists() | ||||||
except Exception as e: | ||||||
raise WorkflowError(f"Failed to check existence of {self.query}", e) | ||||||
raise WorkflowError(f"Failed to check existence of {self.print_query}", e) | ||||||
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. Use The change from To improve the clarity of the exception, use - raise WorkflowError(f"Failed to check existence of {self.print_query}", e)
+ raise WorkflowError(f"Failed to check existence of {self.print_query}") from e Committable suggestion
Suggested change
ToolsRuff
|
||||||
|
||||||
async def managed_retrieve(self): | ||||||
try: | ||||||
|
@@ -173,7 +174,7 @@ async def managed_retrieve(self): | |||||
else: | ||||||
os.remove(local_path) | ||||||
raise WorkflowError( | ||||||
f"Failed to retrieve storage object from {self.query}", e | ||||||
f"Failed to retrieve storage object from {self.print_query}", e | ||||||
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. Use The change from For consistency with the previous instances, use - f"Failed to retrieve storage object from {self.print_query}", e
+ f"Failed to retrieve storage object from {self.print_query}") from e Committable suggestion
Suggested change
|
||||||
) | ||||||
|
||||||
|
||||||
|
@@ -189,14 +190,18 @@ async def managed_remove(self): | |||||
async with self._rate_limiter(Operation.REMOVE): | ||||||
self.remove() | ||||||
except Exception as e: | ||||||
raise WorkflowError(f"Failed to remove storage object {self.query}", e) | ||||||
raise WorkflowError( | ||||||
f"Failed to remove storage object {self.print_query}", e | ||||||
) | ||||||
|
||||||
async def managed_store(self): | ||||||
try: | ||||||
async with self._rate_limiter(Operation.STORE): | ||||||
self.store_object() | ||||||
except Exception as e: | ||||||
raise WorkflowError(f"Failed to store output in storage {self.query}", e) | ||||||
raise WorkflowError( | ||||||
f"Failed to store output in storage {self.print_query}", e | ||||||
) | ||||||
|
||||||
|
||||||
class StorageObjectGlob(StorageObjectBase): | ||||||
|
@@ -219,4 +224,4 @@ async def managed_touch(self): | |||||
async with self._rate_limiter(Operation.TOUCH): | ||||||
self.touch() | ||||||
except Exception as e: | ||||||
raise WorkflowError(f"Failed to touch storage object {self.query}", e) | ||||||
raise WorkflowError(f"Failed to touch storage object {self.print_query}", e) | ||||||
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. Use The change from To improve the clarity of the exception, use - raise WorkflowError(f"Failed to touch storage object {self.print_query}", e)
+ raise WorkflowError(f"Failed to touch storage object {self.print_query}") from e Committable suggestion
Suggested change
ToolsRuff
|
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.
Use
raise ... from e
to distinguish the exception from errors in exception handling.The change from
self.query
toself.print_query
in the error message is consistent with the PR objective of using the safe representation of the query in exception handling scenarios.To improve the clarity of the exception, use
raise ... from e
as suggested by the static analysis hint:Committable suggestion
Tools
Ruff