Skip to content

Commit 6e9cc31

Browse files
committed
Address PR feedback + fix typos
1 parent 970b490 commit 6e9cc31

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/strands/_exception_notes.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
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

97
def 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

0 commit comments

Comments
 (0)