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.
Method | __init__ |
Undocumented |
Method | add_errors |
Add errors in messages to this builder. |
Method | add_fixture_note |
Undocumented |
Method | argument_incompatible_with_supertype |
Undocumented |
Method | bad_proto_variance |
Undocumented |
Method | base_class_definitions_incompatible |
Undocumented |
Method | cannot_determine_type |
Undocumented |
Method | cannot_determine_type_in_base |
Undocumented |
Method | cannot_instantiate_abstract_class |
Undocumented |
Method | cannot_use_function_with_type |
Undocumented |
Method | cant_assign_to_classvar |
Undocumented |
Method | cant_assign_to_final |
Warn about a prohibited assignment to a final attribute. |
Method | cant_assign_to_method |
Undocumented |
Method | cant_override_final |
Undocumented |
Method | clean_copy |
Undocumented |
Method | comparison_method_example_msg |
Undocumented |
Method | concrete_only_assign |
Undocumented |
Method | concrete_only_call |
Undocumented |
Method | copy |
Undocumented |
Method | could_not_infer_type_arguments |
Undocumented |
Method | dangerous_comparison |
Undocumented |
Method | deleted_as_lvalue |
Report an error about using an deleted type as an lvalue. |
Method | deleted_as_rvalue |
Report an error about using an deleted type as an rvalue. |
Method | disable_errors |
Undocumented |
Method | disallowed_any_type |
Undocumented |
Method | does_not_return_value |
Report an error about use of an unusable type. |
Method | duplicate_argument_value |
Undocumented |
Method | explicit_any |
Undocumented |
Method | fail |
Report an error message (unless disabled). |
Method | final_cant_override_writable |
Undocumented |
Method | final_without_value |
Undocumented |
Method | first_argument_for_super_must_be_type |
Undocumented |
Method | format_long_tuple_type |
Format very long tuple type using an ellipsis notation |
Method | forward_operator_not_callable |
Undocumented |
Method | generate_incompatible_tuple_error |
Generate error message for individual incompatible tuple pairs |
Method | has_no_attr |
Report a missing or non-accessible member. |
Method | impossible_intersection |
Undocumented |
Method | incompatible_argument |
Report an error about an incompatible argument type. |
Method | incompatible_argument_note |
Undocumented |
Method | incompatible_conditional_function_def |
Undocumented |
Method | incompatible_operator_assignment |
Undocumented |
Method | incompatible_self_argument |
Undocumented |
Method | incompatible_type_application |
Undocumented |
Method | incompatible_typevar_value |
Undocumented |
Method | incorrect__exit__return |
Undocumented |
Method | incorrectly_returning_any |
Undocumented |
Method | invalid_index_type |
Undocumented |
Method | invalid_keyword_var_arg |
Undocumented |
Method | invalid_signature |
Undocumented |
Method | invalid_signature_for_special_method |
Undocumented |
Method | invalid_var_arg |
Undocumented |
Method | is_errors |
Undocumented |
Method | key_not_in_mapping |
Undocumented |
Method | maybe_note_about_special_args |
Undocumented |
Method | missing_named_argument |
Undocumented |
Method | most_recent_context |
Return a dummy context matching the most recent generated error in current file. |
Method | need_annotation_for_var |
Undocumented |
Method | no_formal_self |
Undocumented |
Method | no_variant_matches_arguments |
Undocumented |
Method | not_callable |
Undocumented |
Method | note |
Report a note (unless disabled). |
Method | note_call |
Undocumented |
Method | note_multiline |
Report as many notes as lines in the message (unless disabled). |
Method | operator_method_signatures_overlap |
Undocumented |
Method | overload_inconsistently_applies_decorator |
Undocumented |
Method | overload_signature_incompatible_with_supertype |
Undocumented |
Method | overloaded_signature_will_never_match |
Undocumented |
Method | overloaded_signatures_arg_specific |
Undocumented |
Method | overloaded_signatures_overlap |
Undocumented |
Method | overloaded_signatures_ret_specific |
Undocumented |
Method | overloaded_signatures_typevar_specific |
Undocumented |
Method | override_target |
Undocumented |
Method | pretty_callable_or_overload |
Undocumented |
Method | pretty_overload |
Undocumented |
Method | print_more |
Undocumented |
Method | protocol_members_cant_be_final |
Undocumented |
Method | read_only_property |
Undocumented |
Method | redundant_cast |
Undocumented |
Method | redundant_condition_in_assert |
Undocumented |
Method | redundant_condition_in_comprehension |
Undocumented |
Method | redundant_condition_in_if |
Undocumented |
Method | redundant_expr |
Undocumented |
Method | redundant_left_operand |
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_non_method_protocol |
Undocumented |
Method | report_protocol_problems |
Report possible protocol conflicts between 'subtype' and 'supertype'. |
Method | requires_int_or_char |
Undocumented |
Method | requires_int_or_single_byte |
Undocumented |
Method | return_type_incompatible_with_supertype |
Undocumented |
Method | reveal_locals |
Undocumented |
Method | reveal_type |
Undocumented |
Method | signature_incompatible_with_supertype |
Undocumented |
Method | signatures_incompatible |
Undocumented |
Method | string_interpolation_mixing_key_and_non_keys |
Undocumented |
Method | string_interpolation_with_star_and_key |
Undocumented |
Method | too_few_arguments |
Undocumented |
Method | too_few_string_formatting_arguments |
Undocumented |
Method | too_many_arguments |
Undocumented |
Method | too_many_arguments_from_typed_dict |
Undocumented |
Method | too_many_positional_arguments |
Undocumented |
Method | too_many_string_formatting_arguments |
Undocumented |
Method | try_report_long_tuple_assignment_error |
Try to generate meaningful error message for very long tuple assignment |
Method | type_arguments_not_allowed |
Undocumented |
Method | type_not_iterable |
Undocumented |
Method | typed_function_untyped_decorator |
Undocumented |
Method | typeddict_context_ambiguous |
Undocumented |
Method | typeddict_key_cannot_be_deleted |
Undocumented |
Method | typeddict_key_must_be_string_literal |
Undocumented |
Method | typeddict_key_not_found |
Undocumented |
Method | typeddict_setdefault_arguments_inconsistent |
Undocumented |
Method | undefined_in_superclass |
Undocumented |
Method | underscore_function_call |
Undocumented |
Method | unexpected_keyword_argument |
Undocumented |
Method | unexpected_typeddict_keys |
Undocumented |
Method | unimported_type_becomes_any |
Undocumented |
Method | unpacking_strings_disallowed |
Undocumented |
Method | unreachable_right_operand |
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_statement |
Undocumented |
Method | unsupported_left_operand |
Undocumented |
Method | unsupported_operand_types |
Report unsupported operand types for a binary operation. |
Method | unsupported_placeholder |
Undocumented |
Method | unsupported_type_type |
Undocumented |
Method | untyped_decorated_function |
Undocumented |
Method | untyped_function_call |
Undocumented |
Method | warn_both_operands_are_from_unions |
Undocumented |
Method | warn_operand_was_from_union |
Undocumented |
Method | wrong_number_values_to_unpack |
Undocumented |
Method | yield_from_invalid_operand_type |
Undocumented |
Instance Variable | disable_count |
Undocumented |
Instance Variable | disable_type_names |
Undocumented |
Instance Variable | errors |
Undocumented |
Instance Variable | modules |
Undocumented |
Undocumented
Parameters | |
actual:int | Undocumented |
tvar_name:str | Undocumented |
expected:int | Undocumented |
context:Context | Undocumented |
Undocumented
Parameters | |
class_name:str | Undocumented |
abstract_attributes:List[ | Undocumented |
context:Context | Undocumented |
Undocumented
Parameters | |
method_name:str | Undocumented |
type_name:str | Undocumented |
context:Context | Undocumented |
Warn about a prohibited assignment to a final attribute.
Pass attr_assign=True
if the assignment assigns to an attribute.
Parameters | |
name:str | Undocumented |
attr_assign:bool | Undocumented |
ctx:Context | Undocumented |
Undocumented
Parameters | |
callee_type:CallableType | Undocumented |
n:int | Undocumented |
context:Context | 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.
Parameters | |
typ:DeletedType | Undocumented |
context:Context | Undocumented |
Parameters | |
typ:DeletedType | Undocumented |
context:Context | Undocumented |
Undocumented
Parameters | |
callee:CallableType | Undocumented |
index:int | Undocumented |
context:Context | Undocumented |
Parameters | |
typ:TupleType | Undocumented |
Returns | |
str | Undocumented |
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.
Parameters | |
original_type:Type | Undocumented |
typ:Type | Undocumented |
member:str | Undocumented |
context:Context | Undocumented |
module_symbol_table:Optional[ | Undocumented |
Returns | |
Type | Undocumented |
Undocumented
Parameters | |
formatted_base_class_list:str | Undocumented |
reason:str | Undocumented |
context:Context | Undocumented |
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).
Parameters | |
n:int | Undocumented |
m:int | Undocumented |
callee:CallableType | Undocumented |
arg_type:Type | Undocumented |
arg_kind:ArgKind | Undocumented |
object_type:Optional[ | Undocumented |
context:Context | Undocumented |
outer_context:Context | Undocumented |
Returns | |
Optional[ | Undocumented |
Undocumented
Parameters | |
original_caller_type:ProperType | Undocumented |
callee_type:ProperType | Undocumented |
context:Context | Undocumented |
code:Optional[ | Undocumented |
Undocumented
Parameters | |
name:str | Undocumented |
arg:Type | Undocumented |
sig:CallableType | Undocumented |
is_classmethod:bool | Undocumented |
context:Context | Undocumented |
Undocumented
Parameters | |
expected_arg_count:int | Undocumented |
actual_arg_count:int | Undocumented |
context:Context | Undocumented |
Undocumented
Parameters | |
callee:CallableType | Undocumented |
typ:Type | Undocumented |
typevar_name:str | Undocumented |
context:Context | Undocumented |
Undocumented
Parameters | |
callee:CallableType | Undocumented |
context:Context | Undocumented |
name:str | Undocumented |
Returns | |
Context | Undocumented |
Undocumented
Parameters | |
node:SymbolNode | Undocumented |
context:Context | Undocumented |
python_version:Optional[ | Undocumented |
Undocumented
Parameters | |
overload:Overloaded | Undocumented |
arg_types:List[ | Undocumented |
context:Context | Undocumented |
code:Optional[ | Undocumented |
Undocumented
Parameters | |
name:str | Undocumented |
name_in_super:str | Undocumented |
supertype:str | Undocumented |
overload:Overloaded | Undocumented |
context:Context | Undocumented |
Undocumented
Parameters | |
name:str | Undocumented |
name_in_super:str | Undocumented |
supertype:str | Undocumented |
Returns | |
str | Undocumented |
Undocumented
Parameters | |
tp:Union[ | Undocumented |
context:Context | Undocumented |
offset:int | Undocumented |
add_class_or_static_decorator:bool | Undocumented |
allow_dups:bool | Undocumented |
code:Optional[ | Undocumented |
Undocumented
Parameters | |
tp:Overloaded | Undocumented |
context:Context | Undocumented |
offset:int | Undocumented |
add_class_or_static_decorator:bool | Undocumented |
allow_dups:bool | Undocumented |
code:Optional[ | Undocumented |
Undocumented
Parameters | |
description:str | Undocumented |
truthiness:bool | Undocumented |
context:Context | Undocumented |
Parameters | |
op_name:str | Undocumented |
context:Context | Undocumented |
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.
Parameters | |
subtype:Union[ | Undocumented |
supertype:Instance | Undocumented |
context:Context | Undocumented |
code:Optional[ | Undocumented |
Undocumented
Parameters | |
name:str | Undocumented |
name_in_super:str | Undocumented |
supertype:str | Undocumented |
context:Context | Undocumented |
original:Optional[ | Undocumented |
override:Optional[ | Undocumented |
Undocumented
Parameters | |
method:str | Undocumented |
other_method:str | Undocumented |
context:Context | Undocumented |
Undocumented
Parameters | |
callee:CallableType | Undocumented |
context:Context | Undocumented |
argument_names:Optional[ | Undocumented |
Undocumented
Parameters | |
callee:CallableType | Undocumented |
arg_type:TypedDictType | Undocumented |
context:Context | Undocumented |
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
Parameters | |
subtype:ProperType | Undocumented |
supertype:ProperType | Undocumented |
context:Context | Undocumented |
msg:str | Undocumented |
subtype_label:Optional[ | Undocumented |
supertype_label:Optional[ | Undocumented |
code:Optional[ | Undocumented |
Returns | |
bool | Undocumented |
Undocumented
Parameters | |
typ:TypedDictType | Undocumented |
item_name:str | Undocumented |
context:Context | Undocumented |
Undocumented
Parameters | |
typ:TypedDictType | Undocumented |
item_name:str | Undocumented |
context:Context | Undocumented |
Undocumented
Parameters | |
callee:CallableType | Undocumented |
name:str | Undocumented |
arg_type:Type | Undocumented |
context:Context | Undocumented |
Undocumented
Parameters | |
typ:TypedDictType | Undocumented |
expected_keys:List[ | Undocumented |
actual_keys:List[ | Undocumented |
context:Context | Undocumented |
Parameters | |
op_name:str | Undocumented |
context:Context | Undocumented |
Undocumented
Parameters | |
callee:CallableType | Undocumented |
context:Context | Undocumented |
Returns | |
Type | Undocumented |