-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #734 from tclose/dont-catch-unhashable
Add note instead of catching and raising unhashable exception
- Loading branch information
Showing
6 changed files
with
78 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,11 +1 @@ | ||
from pathlib import Path | ||
import platformdirs | ||
from pydra._version import __version__ | ||
|
||
user_cache_dir = Path( | ||
platformdirs.user_cache_dir( | ||
appname="pydra", | ||
appauthor="nipype", | ||
version=__version__, | ||
) | ||
) | ||
from .misc import user_cache_dir, add_exc_note # noqa: F401 |
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from pathlib import Path | ||
import platformdirs | ||
from pydra._version import __version__ | ||
|
||
user_cache_dir = Path( | ||
platformdirs.user_cache_dir( | ||
appname="pydra", | ||
appauthor="nipype", | ||
version=__version__, | ||
) | ||
) | ||
|
||
|
||
def add_exc_note(e: Exception, note: str) -> Exception: | ||
"""Adds a note to an exception in a Python <3.11 compatible way | ||
Parameters | ||
---------- | ||
e : Exception | ||
the exception to add the note to | ||
note : str | ||
the note to add | ||
Returns | ||
------- | ||
Exception | ||
returns the exception again | ||
""" | ||
if hasattr(e, "add_note"): | ||
e.add_note(note) | ||
else: | ||
e.args = (e.args[0] + "\n" + note,) | ||
return e |
This file contains 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