Report message at the given line using the current error context. Args: line: line number of error column: column number of error message: message to report code: error code (defaults to 'misc'; not shown for notes) blocker: if Tru
(
self,
line: int,
column: int | None,
message: str,
code: ErrorCode | None = None,
*,
blocker: bool = False,
severity: str = "error",
only_once: bool = False,
origin_span: Iterable[int] | None = None,
offset: int = 0,
end_line: int | None = None,
end_column: int | None = None,
parent_error: ErrorInfo | None = None,
)
| 592 | self.import_ctx = ctx.copy() |
| 593 | |
| 594 | def report( |
| 595 | self, |
| 596 | line: int, |
| 597 | column: int | None, |
| 598 | message: str, |
| 599 | code: ErrorCode | None = None, |
| 600 | *, |
| 601 | blocker: bool = False, |
| 602 | severity: str = "error", |
| 603 | only_once: bool = False, |
| 604 | origin_span: Iterable[int] | None = None, |
| 605 | offset: int = 0, |
| 606 | end_line: int | None = None, |
| 607 | end_column: int | None = None, |
| 608 | parent_error: ErrorInfo | None = None, |
| 609 | ) -> ErrorInfo: |
| 610 | """Report message at the given line using the current error context. |
| 611 | |
| 612 | Args: |
| 613 | line: line number of error |
| 614 | column: column number of error |
| 615 | message: message to report |
| 616 | code: error code (defaults to 'misc'; not shown for notes) |
| 617 | blocker: if True, don't continue analysis after this error |
| 618 | severity: 'error' or 'note' |
| 619 | only_once: if True, only report this exact message once per build |
| 620 | origin_span: lines where `type: ignore`s have effect for this error |
| 621 | (default is [line]) |
| 622 | offset: number of spaces to prefix this message |
| 623 | end_line: if known, end line of error location |
| 624 | end_column: if known, end column of error location |
| 625 | parent_error: an error this note is attached to (for notes only). |
| 626 | """ |
| 627 | if self.scope: |
| 628 | type = self.scope.current_type_name() |
| 629 | if self.scope.ignored > 0: |
| 630 | type = None # Omit type context if nested function |
| 631 | function = self.scope.current_function_name() |
| 632 | else: |
| 633 | type = None |
| 634 | function = None |
| 635 | |
| 636 | # It looks like there is a bug in how we parse f-strings, |
| 637 | # we cannot simply assert this yet. |
| 638 | if end_line is None or end_line < line: |
| 639 | end_line = line |
| 640 | |
| 641 | if column is None: |
| 642 | column = -1 |
| 643 | if end_column is None: |
| 644 | if column == -1: |
| 645 | end_column = -1 |
| 646 | else: |
| 647 | end_column = column + 1 |
| 648 | if line == end_line and end_column <= column: |
| 649 | # Be defensive, similar to the logic for lines above. |
| 650 | end_column = column + 1 |
| 651 |
no test coverage detected