Commit 9de0c68
committed
[requests] Add missing attributes and __init__ to JSONDecodeError stub
requests.exceptions.JSONDecodeError inherits from both InvalidJSONError
(via RequestException) and json.JSONDecodeError. Its custom __init__
explicitly calls CompatJSONDecodeError.__init__(msg, doc, pos) first,
which sets the json.JSONDecodeError instance attributes (doc, pos,
lineno, colno, msg).
However, due to the complex MRO, type checkers may not resolve these
inherited attributes correctly on the requests.JSONDecodeError class.
Explicitly re-declaring them ensures tools like mypy correctly recognize
attributes such as exc.doc when catching requests.JSONDecodeError.
Also adds the proper __init__ signature matching the runtime behavior.
Fixes #151671 parent 81a6d24 commit 9de0c68
1 file changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
18 | 28 | | |
19 | 29 | | |
20 | 30 | | |
| |||
0 commit comments