mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
Improve the SyntaxError constructor; add SyntaxError.print_file_and_line (#13141)
This commit is contained in:
@@ -1963,14 +1963,33 @@ class StopAsyncIteration(Exception):
|
||||
|
||||
class SyntaxError(Exception):
|
||||
msg: str
|
||||
filename: str | None
|
||||
lineno: int | None
|
||||
offset: int | None
|
||||
text: str | None
|
||||
filename: str | None
|
||||
# Errors are displayed differently if this attribute exists on the exception.
|
||||
# The value is always None.
|
||||
print_file_and_line: None
|
||||
if sys.version_info >= (3, 10):
|
||||
end_lineno: int | None
|
||||
end_offset: int | None
|
||||
|
||||
@overload
|
||||
def __init__(self) -> None: ...
|
||||
@overload
|
||||
def __init__(self, msg: object, /) -> None: ...
|
||||
# Second argument is the tuple (filename, lineno, offset, text)
|
||||
@overload
|
||||
def __init__(self, msg: str, info: tuple[str | None, int | None, int | None, str | None], /) -> None: ...
|
||||
if sys.version_info >= (3, 10):
|
||||
# end_lineno and end_offset must both be provided if one is.
|
||||
@overload
|
||||
def __init__(
|
||||
self, msg: str, info: tuple[str | None, int | None, int | None, str | None, int | None, int | None], /
|
||||
) -> None: ...
|
||||
# If you provide more than two arguments, it still creates the SyntaxError, but
|
||||
# the arguments from the info tuple are not parsed. This form is omitted.
|
||||
|
||||
class SystemError(Exception): ...
|
||||
class TypeError(Exception): ...
|
||||
class ValueError(Exception): ...
|
||||
|
||||
Reference in New Issue
Block a user