Commit 1d9e31a
authored
fix: allow None for exc_tb in Traveller.__exit__ annotations (#974)
CPython calls __exit__(None, None, None) when a with block exits without an
exception, so all three parameters must accept None. exc_type and exc_val were
already optional on the travellers, but exc_tb was annotated TracebackType
without | None, so a type checker infers the traveller is not a valid context
manager and reports invalid-context-manager on with pendulum.travel_to(...).
Annotate exc_tb as TracebackType | None in BaseTraveller.__exit__ and the
time_machine-backed Traveller.__exit__ (the other Traveller subclasses inherit
from BaseTraveller).
Closes #9731 parent b99bd14 commit 1d9e31a
1 file changed
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
| 152 | + | |
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| |||
0 commit comments