class MessageBuilder: (source)
Helper class for reporting type checker error messages with parameters. The methods of this class need to be provided with the context within a file; the errors member manages the wider context. IDEA: Support a 'verbose mode' that includes full information about types in error messages and that may otherwise produce more detailed error messages.
Method | __init__ |
Undocumented |
Method | add |
Add errors in messages to this builder. |
Method | add |
Undocumented |
Method | annotation |
Undocumented |
Method | are |
Undocumented |
Method | argument |
Undocumented |
Method | assert |
Undocumented |
Method | bad |
Undocumented |
Method | base |
Undocumented |
Method | cannot |
Undocumented |
Method | cannot |
Undocumented |
Method | cannot |
Undocumented |
Method | cannot |
Undocumented |
Method | cant |
Undocumented |
Method | cant |
Warn about a prohibited assignment to a final attribute. |
Method | cant |
Undocumented |
Method | cant |
Undocumented |
Method | comparison |
Undocumented |
Method | concrete |
Undocumented |
Method | concrete |
Undocumented |
Method | could |
Undocumented |
Method | dangerous |
Undocumented |
Method | deleted |
Report an error about using an deleted type as an lvalue. |
Method | deleted |
Report an error about using an deleted type as an rvalue. |
Method | disable |
Undocumented |
Method | disallowed |
Undocumented |
Method | does |
Report an error about use of an unusable type. |
Method | duplicate |
Undocumented |
Method | explicit |
Undocumented |
Method | fail |
Report an error message (unless disabled). |
Method | filter |
Undocumented |
Method | final |
Undocumented |
Method | final |
Undocumented |
Method | first |
Undocumented |
Method | format |
Format very long tuple type using an ellipsis notation |
Method | forward |
Undocumented |
Method | generate |
Generate error message for individual incompatible tuple pairs |
Method | has |
Report a missing or non-accessible member. |
Method | impossible |
Undocumented |
Method | incompatible |
Report an error about an incompatible argument type. |
Method | incompatible |
Undocumented |
Method | incompatible |
Undocumented |
Method | incompatible |
Undocumented |
Method | incompatible |
Undocumented |
Method | incompatible |
Undocumented |
Method | incompatible |
Undocumented |
Method | incorrect |
Undocumented |
Method | incorrectly |
Undocumented |
Method | invalid |
Undocumented |
Method | invalid |
Undocumented |
Method | invalid |
Undocumented |
Method | invalid |
Undocumented |
Method | invalid |
Undocumented |
Method | key |
Undocumented |
Method | maybe |
Undocumented |
Method | maybe |
Undocumented |
Method | missing |
Undocumented |
Method | need |
Undocumented |
Method | no |
Undocumented |
Method | no |
Undocumented |
Method | not |
Undocumented |
Method | note |
Report a note (unless disabled). |
Method | note |
Undocumented |
Method | note |
Report as many notes as lines in the message (unless disabled). |
Method | operator |
Undocumented |
Method | overload |
Undocumented |
Method | overload |
Undocumented |
Method | overloaded |
Undocumented |
Method | overloaded |
Undocumented |
Method | overloaded |
Undocumented |
Method | overloaded |
Undocumented |
Method | overloaded |
Undocumented |
Method | override |
Undocumented |
Method | possible |
Undocumented |
Method | prefer |
Should we generate simple/fast error messages? |
Method | pretty |
Undocumented |
Method | pretty |
Undocumented |
Method | print |
Undocumented |
Method | protocol |
Undocumented |
Method | read |
Undocumented |
Method | redundant |
Undocumented |
Method | redundant |
Undocumented |
Method | redundant |
Undocumented |
Method | redundant |
Undocumented |
Method | redundant |
Indicates that the left operand of a boolean expression is redundant: it does not change the truth value of the entire condition as a whole. 'op_name' should either be the string "and" or the string "or". |
Method | report |
Report an error or note (unless disabled). |
Method | report |
Undocumented |
Method | report |
Report possible protocol conflicts between 'subtype' and 'supertype'. |
Method | requires |
Undocumented |
Method | requires |
Undocumented |
Method | return |
Undocumented |
Method | reveal |
Undocumented |
Method | reveal |
Undocumented |
Method | signature |
Undocumented |
Method | signatures |
Undocumented |
Method | string |
Undocumented |
Method | string |
Undocumented |
Method | too |
Undocumented |
Method | too |
Undocumented |
Method | too |
Undocumented |
Method | too |
Undocumented |
Method | too |
Undocumented |
Method | too |
Undocumented |
Method | try |
Try to generate meaningful error message for very long tuple assignment |
Method | type |
Undocumented |
Method | type |
Undocumented |
Method | typed |
Undocumented |
Method | typeddict |
Undocumented |
Method | typeddict |
Undocumented |
Method | typeddict |
Undocumented |
Method | typeddict |
Handle error messages for TypedDicts that have unknown keys. |
Method | typeddict |
Undocumented |
Method | undefined |
Undocumented |
Method | unexpected |
Undocumented |
Method | unexpected |
Undocumented |
Method | unimported |
Undocumented |
Method | unpacking |
Undocumented |
Method | unreachable |
Indicates that the right operand of a boolean expression is redundant: it does not change the truth value of the entire condition as a whole. 'op_name' should either be the string "and" or the string "or". |
Method | unreachable |
Undocumented |
Method | unsafe |
Undocumented |
Method | unsupported |
Undocumented |
Method | unsupported |
Report unsupported operand types for a binary operation. |
Method | unsupported |
Undocumented |
Method | unsupported |
Undocumented |
Method | untyped |
Undocumented |
Method | untyped |
Undocumented |
Method | var |
Undocumented |
Method | variable |
Undocumented |
Method | warn |
Undocumented |
Method | warn |
Undocumented |
Method | wrong |
Undocumented |
Method | yield |
Undocumented |
Instance Variable | errors |
Undocumented |
Instance Variable | modules |
Undocumented |
Instance Variable | _disable |
Undocumented |
int
, name: str
, type_name: str|None
, name_in_supertype: str
, arg_type_in_supertype: Type
, supertype: str
, context: Context
, secondary_context: Context
):
(source)
¶
Undocumented
int
, tvar_name: str
, expected: int
, context: Context
):
(source)
¶
Undocumented
str
, base1: TypeInfo
, base2: TypeInfo
, context: Context
):
(source)
¶
Undocumented
str
, abstract_attributes: dict[ str, bool]
, context: Context
):
(source)
¶
Undocumented
str
, type_name: str
, context: Context
):
(source)
¶
Undocumented
Warn about a prohibited assignment to a final attribute. Pass `attr_assign=True` if the assignment assigns to an attribute.
CallableType
, n: int
, context: Context
):
(source)
¶
Undocumented
Report an error about using an deleted type as an lvalue. Currently, this only occurs when trying to assign to an exception variable outside the local except: blocks.
str
, context: Context|None
, *, code: ErrorCode|None
= None, file: str|None
= None, allow_dups: bool
= False, secondary_context: Context|None
= None):
(source)
¶
Report an error message (unless disabled).
bool|Callable[ [ str, ErrorInfo], bool]
= True, save_filtered_errors: bool
= False) -> ErrorWatcher
:
(source)
¶
Undocumented
list[ Type]
, rhs_types: list[ Type]
, context: Context
, msg: message_registry.ErrorMessage
):
(source)
¶
Generate error message for individual incompatible tuple pairs
Type
, typ: Type
, member: str
, context: Context
, module_symbol_table: SymbolTable|None
= None) -> Type
:
(source)
¶
Report a missing or non-accessible member. original_type is the top-level type on which the error occurred. typ is the actual type that is missing the member. These can be different, e.g., in a union, original_type will be the union and typ will be the specific item in the union that does not have the member attribute. 'module_symbol_table' is passed to this function if the type for which we are trying to get a member was originally a module. The SymbolTable allows us to look up and suggests attributes of the module since they are not directly available on original_type If member corresponds to an operator, use the corresponding operator name in the messages. Return type Any.
str
, reason: str
, context: Context
):
(source)
¶
Undocumented
int
, m: int
, callee: CallableType
, arg_type: Type
, arg_kind: ArgKind
, object_type: Type|None
, context: Context
, outer_context: Context
) -> ErrorCode|None
:
(source)
¶
Report an error about an incompatible argument type. The argument type is arg_type, argument number is n and the callee type is 'callee'. If the callee represents a method that corresponds to an operator, use the corresponding operator name in the messages. Return the error code that used for the argument (multiple error codes are possible).
ProperType
, callee_type: ProperType
, context: Context
, code: ErrorCode|None
):
(source)
¶
Undocumented
FuncDef
, old_type: FunctionLike
, new_type: FunctionLike
):
(source)
¶
Undocumented
str
, arg: Type
, sig: CallableType
, is_classmethod: bool
, context: Context
):
(source)
¶
Undocumented
int
, actual_arg_count: int
, context: Context
):
(source)
¶
Undocumented
CallableType
, typ: Type
, typevar_name: str
, context: Context
):
(source)
¶
Undocumented
Type
, expected_type: Type
, base_str: str
, context: Context
, *, code: ErrorCode
):
(source)
¶
Undocumented
Type
, context: Context
, method_name: str
):
(source)
¶
Undocumented
ProperType
, callee_type: ProperType
, context: Context
, code: ErrorCode|None
= None):
(source)
¶
Undocumented
SymbolNode
, context: Context
, python_version: tuple[ int, int]|None
= None):
(source)
¶
Undocumented
Overloaded
, arg_types: list[ Type]
, context: Context
, *, code: ErrorCode|None
= None):
(source)
¶
Undocumented
str
, context: Context
, file: str|None
= None, origin: Context|None
= None, offset: int
= 0, allow_dups: bool
= False, *, code: ErrorCode|None
= None, secondary_context: Context|None
= None):
(source)
¶
Report a note (unless disabled).
Type
, call: Type
, context: Context
, *, code: ErrorCode|None
):
(source)
¶
Undocumented
str
, context: Context
, file: str|None
= None, offset: int
= 0, allow_dups: bool
= False, code: ErrorCode|None
= None, *, secondary_context: Context|None
= None):
(source)
¶
Report as many notes as lines in the message (unless disabled).
TypeInfo
, reverse_method: str
, forward_class: Type
, forward_method: str
, context: Context
):
(source)
¶
Undocumented
str
, name_in_super: str
, supertype: str
, context: Context
):
(source)
¶
Undocumented
int
, index2: int
, context: Context
):
(source)
¶
Undocumented
Should we generate simple/fast error messages? If errors aren't shown to the user, we don't want to waste cyles producing complex error messages.
CallableType|Overloaded
, context: Context
, *, offset: int
= 0, add_class_or_static_decorator: bool
= False, allow_dups: bool
= False, code: ErrorCode|None
= None):
(source)
¶
Undocumented
Overloaded
, context: Context
, offset: int
, *, add_class_or_static_decorator: bool
= False, allow_dups: bool
= False, code: ErrorCode|None
= None, skip_self: bool
= False):
(source)
¶
Undocumented
Sequence[ Any]
, context: Context
, offset: int
, max_items: int
, *, code: ErrorCode|None
= None):
(source)
¶
Undocumented
Indicates that the left operand of a boolean expression is redundant: it does not change the truth value of the entire condition as a whole. 'op_name' should either be the string "and" or the string "or".
str
, context: Context|None
, severity: str
, *, code: ErrorCode|None
= None, file: str|None
= None, origin: Context|None
= None, offset: int
= 0, allow_dups: bool
= False, secondary_context: Context|None
= None):
(source)
¶
Report an error or note (unless disabled). Note that context controls where error is reported, while origin controls where # type: ignore comments have effect.
TypeInfo
, members: list[ str]
, context: Context
):
(source)
¶
Undocumented
(((Instance|TupleType)|TypedDictType)|TypeType)|CallableType
, supertype: Instance
, context: Context
, *, code: ErrorCode|None
):
(source)
¶
Report possible protocol conflicts between 'subtype' and 'supertype'. This includes missing members, incompatible types, and incompatible attribute flags, such as settable vs read-only or class variable vs instance variable.
str
, name_in_supertype: str
, supertype: str
, original: Type
, override: Type
, context: Context
):
(source)
¶
Undocumented
str
, name_in_super: str
, supertype: str
, context: Context
, original: FunctionLike|None
= None, override: FunctionLike|None
= None):
(source)
¶
Undocumented
CallableType
, context: Context
, argument_names: Sequence[ str|None]|None
):
(source)
¶
Undocumented
CallableType
, arg_type: TypedDictType
, context: Context
):
(source)
¶
Undocumented
ProperType
, supertype: ProperType
, context: Context
, msg: message_registry.ErrorMessage
, subtype_label: str|None
= None, supertype_label: str|None
= None) -> bool
:
(source)
¶
Try to generate meaningful error message for very long tuple assignment Returns a bool: True when generating long tuple assignment error, False when no such error reported
TypedDictType
, item_name: str
, context: Context
):
(source)
¶
Undocumented
TypedDictType
, item_name: str
, context: Context
, setitem: bool
= False):
(source)
¶
Handle error messages for TypedDicts that have unknown keys. Note, that we differentiate in between reading a value and setting a value. Setting a value on a TypedDict is an 'unknown-key' error, whereas reading it is the more serious/general 'item' error.
Type
, expected: Type
, context: Context
):
(source)
¶
Undocumented
CallableType
, name: str
, arg_type: Type
, context: Context
):
(source)
¶
Undocumented
TypedDictType
, expected_keys: list[ str]
, actual_keys: list[ str]
, context: Context
):
(source)
¶
Undocumented
Indicates that the right operand of a boolean expression is redundant: it does not change the truth value of the entire condition as a whole. 'op_name' should either be the string "and" or the string "or".
str
, left_type: Any
, right_type: Any
, context: Context
, *, code: ErrorCode
= codes.OPERATOR):
(source)
¶
Report unsupported operand types for a binary operation. Types can be Type objects or strings.