Commit 1ad4593
committed
fix: Make context manager __exit__/__aexit__ signatures compatible with typing protocols
Updates AsyncContextManager.__aexit__ and SyncContextManager.__exit__ to use
Optional types for exception parameters (exc_type, exc_val, traceback) to match
the standard Python typing protocols.
This aligns with the official type definitions in typeshed where
AbstractContextManager and AbstractAsyncContextManager define these parameters
as Optional since they are None when no exception occurs.
Ref: https://github.com/python/typeshed/blob/9317dc62bd4fb46b8b48ce5353286cab80308d47/stdlib/contextlib.pyi#L52-L54
Fixes type checker compatibility issues when using BrowserContext with
type checkers that enforce strict protocol compliance.1 parent 6157d89 commit 1ad4593
2 files changed
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
100 | | - | |
101 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
146 | | - | |
147 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| |||
0 commit comments