File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change 11"""Exception note utilities for Python 3.10+ compatibility."""
22
3- import sys
4-
5- # add_note was add_note in 3.11 - we hoist to a constant for facilitate testing
6- supports_add_note = sys .version_info >= (3 , 11 )
3+ # add_note was added in 3.11 - we hoist to a constant to facilitate testing
4+ supports_add_note = hasattr (Exception , "add_note" )
75
86
97def add_exception_note (exception : Exception , note : str ) -> None :
108 """Add a note to an exception, compatible with Python 3.10+.
119
12- Uses add_note() in Python 3.11+ or modifies the exception message in Python 3.10 .
10+ Uses add_note() if it's available ( Python 3.11+) or modifies the exception message if it is not .
1311 """
1412 if supports_add_note :
1513 # we ignore the mypy error because the version-check for add_note is extracted into a constant up above and
You can’t perform that action at this time.
0 commit comments