| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Arguably these are true positives: line can clearly be None |
Sorry, something went wrong.
|
Diff from mypy_primer, showing the effect of this PR on open source code: werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/debug/tbtools.py:378: error: Unsupported operand types for - ("None" and "int") [operator]
+ src/werkzeug/debug/tbtools.py:378: note: Left operand is of type "Optional[int]"
pyp (https://github.com/hauntsaninja/pyp)
+ pyp.py:641: error: Argument 1 to "code_for_line" has incompatible type "Optional[int]"; expected "int"
core (https://github.com/home-assistant/core)
+ homeassistant/util/async_.py:158: error: Item "None" of "Optional[str]" has no attribute "strip" [union-attr]
+ homeassistant/util/async_.py:164: error: Item "None" of "Optional[str]" has no attribute "strip" [union-attr]
+ homeassistant/helpers/frame.py:112: error: Item "None" of "Optional[str]" has no attribute "strip" [union-attr]
|
Sorry, something went wrong.
|
@AlexWaygood any idea under what circumstances lineno can be None? edit: I got misled by something, removed some noise |
Sorry, something went wrong.
|
In practice it looks like lineno's in traceback come from https://github.com/python/cpython/blob/b27195332e91e932501f16cf9877761b218a9c99/Lib/traceback.py#L329 which we have as an int Line 520 in e3d4bdc |
Sorry, something went wrong.
|
https://github.com/python/cpython/blob/b27195332e91e932501f16cf9877761b218a9c99/Lib/traceback.py#L305 looks pretty reachable to me, but I'll confess I don't know what real-life code ends up with us getting there :) |
Sorry, something went wrong.
|
So should we be changing TracebackType.tb_lineno? |
Sorry, something went wrong.
|
I don't know. I'm not an exception-handling expert, and the language reference doesn't shed much light here. Feel free to revert the int -> int | None changes if you're confident I'm incorrect here :) |
Sorry, something went wrong.
|
This might have something to do with #6769. Presumably traceback line numbers come from stack frames. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Source code here: https://github.com/python/cpython/blob/b27195332e91e932501f16cf9877761b218a9c99/Lib/traceback.py#L243