module documentation
(source)

Message constants for generating error messages during type checking.

Literal messages should be defined as constants in this module so they won't get out of sync if used in more than one place, and so that they can be easily introspected. These messages are ultimately consumed by messages.MessageBuilder.fail(). For more non-trivial message generation, add a method to MessageBuilder and call this instead.

Class ​Error​Message Undocumented
Constant ALL​_MUST​_BE​_SEQ​_STR Undocumented
Constant ARGUMENT​_TYPE​_EXPECTED Undocumented
Constant BAD​_CONSTRUCTOR​_TYPE Undocumented
Constant BARE​_GENERIC Undocumented
Constant CANNOT​_ACCESS​_FINAL​_INSTANCE​_ATTR Undocumented
Constant CANNOT​_ACCESS​_INIT Undocumented
Constant CANNOT​_ASSIGN​_TO​_METHOD Undocumented
Constant CANNOT​_ASSIGN​_TO​_TYPE Undocumented
Constant CANNOT​_INFER​_LAMBDA​_TYPE Undocumented
Constant CANNOT​_INHERIT​_FROM​_FINAL Undocumented
Constant CANNOT​_INSTANTIATE​_PROTOCOL Undocumented
Constant CANNOT​_MAKE​_DELETABLE​_FINAL Undocumented
Constant CANNOT​_OVERRIDE​_CLASS​_VAR Undocumented
Constant CANNOT​_OVERRIDE​_INSTANCE​_VAR Undocumented
Constant CANNOT​_USE​_TYPEVAR​_AS​_EXPRESSION Undocumented
Constant CLASS​_VAR​_OUTSIDE​_OF​_CLASS Undocumented
Constant CLASS​_VAR​_WITH​_TYPEVARS Undocumented
Constant CONTIGUOUS​_ITERABLE​_EXPECTED Undocumented
Constant DEPENDENT​_FINAL​_IN​_CLASS​_BODY Undocumented
Constant DESCRIPTOR​_GET​_NOT​_CALLABLE Undocumented
Constant DESCRIPTOR​_SET​_NOT​_CALLABLE Undocumented
Constant DUPLICATE​_TYPE​_SIGNATURES Undocumented
Constant ERASED​_SELF​_TYPE​_NOT​_SUPERTYPE Undocumented
Constant FORMAT​_REQUIRES​_MAPPING Undocumented
Constant FUNCTION​_ALWAYS​_TRUE Undocumented
Constant FUNCTION​_PARAMETER​_CANNOT​_BE​_COVARIANT Undocumented
Constant FUNCTION​_TYPE​_EXPECTED Undocumented
Constant GENERIC​_CLASS​_VAR​_ACCESS Undocumented
Constant GENERIC​_INSTANCE​_VAR​_CLASS​_ACCESS Undocumented
Constant IMPLICIT​_GENERIC​_ANY​_BUILTIN Undocumented
Constant INCOMPATIBLE​_IMPORT​_OF Undocumented
Constant INCOMPATIBLE​_REDEFINITION Undocumented
Constant INCOMPATIBLE​_RETURN​_VALUE​_TYPE Undocumented
Constant INCOMPATIBLE​_TYPES Undocumented
Constant INCOMPATIBLE​_TYPES​_IN​_ASSIGNMENT Undocumented
Constant INCOMPATIBLE​_TYPES​_IN​_ASYNC​_FOR Undocumented
Constant INCOMPATIBLE​_TYPES​_IN​_ASYNC​_WITH​_AENTER Undocumented
Constant INCOMPATIBLE​_TYPES​_IN​_ASYNC​_WITH​_AEXIT Undocumented
Constant INCOMPATIBLE​_TYPES​_IN​_AWAIT Undocumented
Constant INCOMPATIBLE​_TYPES​_IN​_STR​_INTERPOLATION Undocumented
Constant INCOMPATIBLE​_TYPES​_IN​_YIELD Undocumented
Constant INCOMPATIBLE​_TYPES​_IN​_YIELD​_FROM Undocumented
Constant INCOMPATIBLE​_TYPEVAR​_VALUE Undocumented
Constant INCONSISTENT​_ABSTRACT​_OVERLOAD Undocumented
Constant INVALID​_EXCEPTION Undocumented
Constant INVALID​_EXCEPTION​_TYPE Undocumented
Constant INVALID​_GENERATOR​_RETURN​_ITEM​_TYPE Undocumented
Constant INVALID​_IMPLICIT​_RETURN Undocumented
Constant INVALID​_NEW​_TYPE Undocumented
Constant INVALID​_RETURN​_TYPE​_FOR​_ASYNC​_GENERATOR Undocumented
Constant INVALID​_RETURN​_TYPE​_FOR​_GENERATOR Undocumented
Constant INVALID​_SELF​_TYPE​_OR​_EXTRA​_ARG Undocumented
Constant INVALID​_SLICE​_INDEX Undocumented
Constant INVALID​_TUPLE​_INDEX​_TYPE Undocumented
Constant INVALID​_TYPE​_RAW​_ENUM​_VALUE Undocumented
Constant INVALID​_TYPEDDICT​_ARGS Undocumented
Constant INVALID​_TYPEVAR​_ARG​_BOUND Undocumented
Constant INVALID​_TYPEVAR​_ARG​_VALUE Undocumented
Constant INVALID​_TYPEVAR​_AS​_TYPEARG Undocumented
Constant ITERABLE​_TYPE​_EXPECTED Undocumented
Constant KEYWORD​_ARGUMENT​_REQUIRES​_STR​_KEY​_TYPE Undocumented
Constant MALFORMED​_ASSERT Undocumented
Constant MISSING​_OR​_INVALID​_SELF​_TYPE Undocumented
Constant MISSING​_RETURN​_STATEMENT Undocumented
Constant MODULE​_LEVEL​_GETATTRIBUTE Undocumented
Constant MULTIPLE​_OVERLOADS​_REQUIRED Undocumented
Constant MUST​_HAVE​_NONE​_RETURN​_TYPE Undocumented
Constant NAME​_NOT​_IN​_SLOTS Undocumented
Constant NO​_RETURN​_EXPECTED Undocumented
Constant NO​_RETURN​_VALUE​_EXPECTED Undocumented
Constant NON​_INSTANCE​_NEW​_TYPE Undocumented
Constant NOT​_CALLABLE Undocumented
Constant ONLY​_CLASS​_APPLICATION Undocumented
Constant PYTHON2​_PRINT​_FILE​_TYPE Undocumented
Constant READ​_ONLY​_PROPERTY​_OVERRIDES​_READ​_WRITE Undocumented
Constant RETURN​_IN​_ASYNC​_GENERATOR Undocumented
Constant RETURN​_TYPE​_CANNOT​_BE​_CONTRAVARIANT Undocumented
Constant RETURN​_TYPE​_EXPECTED Undocumented
Constant RETURN​_VALUE​_EXPECTED Undocumented
Constant RUNTIME​_PROTOCOL​_EXPECTED Undocumented
Constant SUPER​_ARG​_2​_NOT​_INSTANCE​_OF​_ARG​_1 Undocumented
Constant SUPER​_ENCLOSING​_POSITIONAL​_ARGS​_REQUIRED Undocumented
Constant SUPER​_OUTSIDE​_OF​_METHOD​_NOT​_SUPPORTED Undocumented
Constant SUPER​_POSITIONAL​_ARGS​_REQUIRED Undocumented
Constant SUPER​_VARARGS​_NOT​_SUPPORTED Undocumented
Constant SUPER​_WITH​_SINGLE​_ARG​_NOT​_SUPPORTED Undocumented
Constant TARGET​_CLASS​_HAS​_NO​_BASE​_CLASS Undocumented
Constant TOO​_FEW​_ARGS​_FOR​_SUPER Undocumented
Constant TOO​_MANY​_ARGS​_FOR​_SUPER Undocumented
Constant TOO​_MANY​_UNION​_COMBINATIONS Undocumented
Constant TUPLE​_INDEX​_OUT​_OF​_RANGE Undocumented
Constant TYPE​_ALWAYS​_TRUE Undocumented
Constant TYPE​_ALWAYS​_TRUE​_UNIONTYPE Undocumented
Constant TYPE​_GUARD​_POS​_ARG​_REQUIRED Undocumented
Constant TYPEDDICT​_KEY​_MUST​_BE​_STRING​_LITERAL Undocumented
Constant TYPEVAR​_BOUND​_MUST​_BE​_TYPE Undocumented
Constant TYPEVAR​_UNEXPECTED​_ARGUMENT Undocumented
Constant TYPEVAR​_VARIANCE​_DEF Undocumented
Constant UNSUPPORTED​_ARG​_1​_FOR​_SUPER Undocumented
Constant UNSUPPORTED​_ARG​_2​_FOR​_SUPER Undocumented
Constant YIELD​_VALUE​_EXPECTED Undocumented
ALL_MUST_BE_SEQ_STR = (source)

Undocumented

Value
ErrorMessage('Type of __all__ must be {}, not {}')
ARGUMENT_TYPE_EXPECTED = (source)

Undocumented

Value
ErrorMessage('Function is missing a type annotation for one or more arguments', codes.NO_UNTYPED_DEF
)
BAD_CONSTRUCTOR_TYPE = (source)

Undocumented

Value
ErrorMessage('Unsupported decorated constructor type')
BARE_GENERIC: str = (source)

Undocumented

Value
'Missing type parameters for generic type {}'
CANNOT_ACCESS_FINAL_INSTANCE_ATTR: str = (source)

Undocumented

Value
'Cannot access final instance attribute "{}" on class object'
CANNOT_ACCESS_INIT: str = (source)

Undocumented

Value
'Cannot access "__init__" directly'
CANNOT_ASSIGN_TO_METHOD: str = (source)

Undocumented

Value
'Cannot assign to a method'
CANNOT_ASSIGN_TO_TYPE: str = (source)

Undocumented

Value
'Cannot assign to a type'
CANNOT_INFER_LAMBDA_TYPE = (source)

Undocumented

Value
ErrorMessage('Cannot infer type of lambda')
CANNOT_INHERIT_FROM_FINAL = (source)

Undocumented

Value
ErrorMessage('Cannot inherit from final class "{}"')
CANNOT_INSTANTIATE_PROTOCOL = (source)

Undocumented

Value
ErrorMessage('Cannot instantiate protocol class "{}"')
CANNOT_MAKE_DELETABLE_FINAL = (source)

Undocumented

Value
ErrorMessage('Deletable attribute cannot be final')
CANNOT_OVERRIDE_CLASS_VAR = (source)

Undocumented

Value
ErrorMessage('Cannot override class variable (previously declared on base class 
"{}") with instance variable')
CANNOT_OVERRIDE_INSTANCE_VAR = (source)

Undocumented

Value
ErrorMessage('Cannot override instance variable (previously declared on base cla
ss "{}") with class variable')
CANNOT_USE_TYPEVAR_AS_EXPRESSION: str = (source)

Undocumented

Value
'Type variable "{}.{}" cannot be used as an expression'
CLASS_VAR_OUTSIDE_OF_CLASS: str = (source)

Undocumented

Value
'ClassVar can only be used for assignments in class body'
CLASS_VAR_WITH_TYPEVARS: str = (source)

Undocumented

Value
'ClassVar cannot contain type variables'
CONTIGUOUS_ITERABLE_EXPECTED = (source)

Undocumented

Value
ErrorMessage('Contiguous iterable with same type expected')
DEPENDENT_FINAL_IN_CLASS_BODY = (source)

Undocumented

Value
ErrorMessage('Final name declared in class body cannot depend on type variables'
)
DESCRIPTOR_GET_NOT_CALLABLE: str = (source)

Undocumented

Value
'{}.__get__ is not callable'
DESCRIPTOR_SET_NOT_CALLABLE = (source)

Undocumented

Value
ErrorMessage('{}.__set__ is not callable')
DUPLICATE_TYPE_SIGNATURES: str = (source)

Undocumented

Value
'Function has duplicate type signatures'
ERASED_SELF_TYPE_NOT_SUPERTYPE = (source)

Undocumented

Value
ErrorMessage('The erased type of self "{}" is not a supertype of its class "{}"'
)
FORMAT_REQUIRES_MAPPING: str = (source)

Undocumented

Value
'Format requires a mapping'
FUNCTION_ALWAYS_TRUE = (source)

Undocumented

Value
ErrorMessage('Function {} could always be true in boolean context',
             code=codes.TRUTHY_BOOL)
FUNCTION_PARAMETER_CANNOT_BE_COVARIANT = (source)

Undocumented

Value
ErrorMessage('Cannot use a covariant type variable as a parameter')
FUNCTION_TYPE_EXPECTED = (source)

Undocumented

Value
ErrorMessage('Function is missing a type annotation', codes.NO_UNTYPED_DEF)
GENERIC_CLASS_VAR_ACCESS: str = (source)

Undocumented

Value
'Access to generic class variables is ambiguous'
GENERIC_INSTANCE_VAR_CLASS_ACCESS: str = (source)

Undocumented

Value
'Access to generic instance variables via class is ambiguous'
IMPLICIT_GENERIC_ANY_BUILTIN: str = (source)

Undocumented

Value
'Implicit generic "Any". Use "{}" and specify generic parameters'
INCOMPATIBLE_IMPORT_OF: str = (source)

Undocumented

Value
'Incompatible import of'
INCOMPATIBLE_REDEFINITION = (source)

Undocumented

Value
ErrorMessage('Incompatible redefinition')
INCOMPATIBLE_RETURN_VALUE_TYPE = (source)

Undocumented

Value
ErrorMessage('Incompatible return value type', codes.RETURN_VALUE)
INCOMPATIBLE_TYPES: str = (source)

Undocumented

Value
'Incompatible types'
INCOMPATIBLE_TYPES_IN_ASSIGNMENT: str = (source)

Undocumented

Value
'Incompatible types in assignment'
INCOMPATIBLE_TYPES_IN_ASYNC_FOR: str = (source)

Undocumented

Value
'Incompatible types in "async for"'
INCOMPATIBLE_TYPES_IN_ASYNC_WITH_AENTER: str = (source)

Undocumented

Value
'Incompatible types in "async with" for "__aenter__"'
INCOMPATIBLE_TYPES_IN_ASYNC_WITH_AEXIT: str = (source)

Undocumented

Value
'Incompatible types in "async with" for "__aexit__"'
INCOMPATIBLE_TYPES_IN_AWAIT = (source)

Undocumented

Value
ErrorMessage('Incompatible types in "await"')
INCOMPATIBLE_TYPES_IN_STR_INTERPOLATION: str = (source)

Undocumented

Value
'Incompatible types in string interpolation'
INCOMPATIBLE_TYPES_IN_YIELD = (source)

Undocumented

Value
ErrorMessage('Incompatible types in "yield"')
INCOMPATIBLE_TYPES_IN_YIELD_FROM = (source)

Undocumented

Value
ErrorMessage('Incompatible types in "yield from"')
INCOMPATIBLE_TYPEVAR_VALUE: str = (source)

Undocumented

Value
'Value of type variable "{}" of {} cannot be {}'
INCONSISTENT_ABSTRACT_OVERLOAD = (source)

Undocumented

Value
ErrorMessage('Overloaded method has both abstract and non-abstract variants')
INVALID_EXCEPTION = (source)

Undocumented

Value
ErrorMessage('Exception must be derived from BaseException')
INVALID_EXCEPTION_TYPE = (source)

Undocumented

Value
ErrorMessage('Exception type must be derived from BaseException')
INVALID_GENERATOR_RETURN_ITEM_TYPE = (source)

Undocumented

Value
ErrorMessage('The return type of a generator function must be None in its third 
type parameter in Python 2')
INVALID_IMPLICIT_RETURN = (source)

Undocumented

Value
ErrorMessage('Implicit return in function which does not return')
INVALID_NEW_TYPE = (source)

Undocumented

Value
ErrorMessage('Incompatible return type for "__new__"')
INVALID_RETURN_TYPE_FOR_ASYNC_GENERATOR = (source)

Undocumented

Value
ErrorMessage('The return type of an async generator function should be "AsyncGen
erator" or one of its supertypes')
INVALID_RETURN_TYPE_FOR_GENERATOR = (source)

Undocumented

Value
ErrorMessage('The return type of a generator function should be "Generator" or o
ne of its supertypes')
INVALID_SELF_TYPE_OR_EXTRA_ARG = (source)

Undocumented

Value
ErrorMessage('Invalid type for self, or extra argument type in function annotati
on')
INVALID_SLICE_INDEX = (source)

Undocumented

Value
ErrorMessage('Slice index must be an integer or None')
INVALID_TUPLE_INDEX_TYPE = (source)

Undocumented

Value
ErrorMessage('Invalid tuple index type')
INVALID_TYPE_RAW_ENUM_VALUE: str = (source)

Undocumented

Value
'Invalid type: try using Literal[{}.{}] instead?'
INVALID_TYPEDDICT_ARGS = (source)

Undocumented

Value
ErrorMessage('Expected keyword arguments, {...}, or dict(...) in TypedDict const
ructor')
INVALID_TYPEVAR_ARG_BOUND: str = (source)

Undocumented

Value
'Type argument {} of "{}" must be a subtype of {}'
INVALID_TYPEVAR_ARG_VALUE: str = (source)

Undocumented

Value
'Invalid type argument value for "{}"'
INVALID_TYPEVAR_AS_TYPEARG: str = (source)

Undocumented

Value
'Type variable "{}" not valid as type argument value for "{}"'
ITERABLE_TYPE_EXPECTED = (source)

Undocumented

Value
ErrorMessage('Invalid type \'{}\' for *expr (iterable expected)')
KEYWORD_ARGUMENT_REQUIRES_STR_KEY_TYPE = (source)

Undocumented

Value
ErrorMessage('Keyword argument only valid with "str" key type in call to "dict"'
)
MALFORMED_ASSERT = (source)

Undocumented

Value
ErrorMessage('Assertion is always true, perhaps remove parentheses?')
MISSING_OR_INVALID_SELF_TYPE = (source)

Undocumented

Value
ErrorMessage('Self argument missing for a non-static method (or an invalid type 
for self)')
MISSING_RETURN_STATEMENT = (source)

Undocumented

Value
ErrorMessage('Missing return statement', codes.RETURN)
MODULE_LEVEL_GETATTRIBUTE = (source)

Undocumented

Value
ErrorMessage('__getattribute__ is not valid at the module level')
MULTIPLE_OVERLOADS_REQUIRED = (source)

Undocumented

Value
ErrorMessage('Single overload definition, multiple required')
MUST_HAVE_NONE_RETURN_TYPE = (source)

Undocumented

Value
ErrorMessage('The return type of "{}" must be None')
NAME_NOT_IN_SLOTS = (source)

Undocumented

Value
ErrorMessage('Trying to assign name "{}" that is not in "__slots__" of type "{}"'
)
NO_RETURN_EXPECTED = (source)

Undocumented

Value
ErrorMessage('Return statement in function which does not return')
NO_RETURN_VALUE_EXPECTED = (source)

Undocumented

Value
ErrorMessage('No return value expected', codes.RETURN_VALUE)
NON_INSTANCE_NEW_TYPE = (source)

Undocumented

Value
ErrorMessage('"__new__" must return a class instance (got {})')
NOT_CALLABLE: str = (source)

Undocumented

Value
'{} not callable'
ONLY_CLASS_APPLICATION = (source)

Undocumented

Value
ErrorMessage('Type application is only supported for generic classes')
PYTHON2_PRINT_FILE_TYPE: str = (source)

Undocumented

Value
'Argument "file" to "print" has incompatible type "{}"; expected "{}"'
READ_ONLY_PROPERTY_OVERRIDES_READ_WRITE = (source)

Undocumented

Value
ErrorMessage('Read-only property cannot override read-write property')
RETURN_IN_ASYNC_GENERATOR = (source)

Undocumented

Value
ErrorMessage('"return" with value in async generator is not allowed')
RETURN_TYPE_CANNOT_BE_CONTRAVARIANT = (source)

Undocumented

Value
ErrorMessage('Cannot use a contravariant type variable as return type')
RETURN_TYPE_EXPECTED = (source)

Undocumented

Value
ErrorMessage('Function is missing a return type annotation', codes.NO_UNTYPED_DEF
)
RETURN_VALUE_EXPECTED = (source)

Undocumented

Value
ErrorMessage('Return value expected', codes.RETURN_VALUE)
RUNTIME_PROTOCOL_EXPECTED = (source)

Undocumented

Value
ErrorMessage('Only @runtime_checkable protocols can be used with instance and cl
ass checks')
SUPER_ARG_2_NOT_INSTANCE_OF_ARG_1 = (source)

Undocumented

Value
ErrorMessage('Argument 2 for "super" not an instance of argument 1')
SUPER_ENCLOSING_POSITIONAL_ARGS_REQUIRED = (source)

Undocumented

Value
ErrorMessage('super() requires one or more positional arguments in enclosing fun
ction')
SUPER_OUTSIDE_OF_METHOD_NOT_SUPPORTED = (source)

Undocumented

Value
ErrorMessage('super() outside of a method is not supported')
SUPER_POSITIONAL_ARGS_REQUIRED = (source)

Undocumented

Value
ErrorMessage('"super" only accepts positional arguments')
SUPER_VARARGS_NOT_SUPPORTED = (source)

Undocumented

Value
ErrorMessage('Varargs not supported with "super"')
SUPER_WITH_SINGLE_ARG_NOT_SUPPORTED = (source)

Undocumented

Value
ErrorMessage('"super" with a single argument not supported')
TARGET_CLASS_HAS_NO_BASE_CLASS = (source)

Undocumented

Value
ErrorMessage('Target class has no base class')
TOO_FEW_ARGS_FOR_SUPER = (source)

Undocumented

Value
ErrorMessage('Too few arguments for "super"', codes.CALL_ARG)
TOO_MANY_ARGS_FOR_SUPER = (source)

Undocumented

Value
ErrorMessage('Too many arguments for "super"')
TOO_MANY_UNION_COMBINATIONS = (source)

Undocumented

Value
ErrorMessage('Not all union combinations were tried because there are too many u
nions')
TUPLE_INDEX_OUT_OF_RANGE = (source)

Undocumented

Value
ErrorMessage('Tuple index out of range')
TYPE_ALWAYS_TRUE = (source)

Undocumented

Value
ErrorMessage('{} which does not implement __bool__ or __len__ so it could always
 be true in boolean context',
             code=codes.TRUTHY_BOOL)
TYPE_ALWAYS_TRUE_UNIONTYPE = (source)

Undocumented

Value
ErrorMessage('{} of which no members implement __bool__ or __len__ so it could a
lways be true in boolean context',
             code=codes.TRUTHY_BOOL)
TYPE_GUARD_POS_ARG_REQUIRED = (source)

Undocumented

Value
ErrorMessage('Type guard requires positional argument')
TYPEDDICT_KEY_MUST_BE_STRING_LITERAL = (source)

Undocumented

Value
ErrorMessage('Expected TypedDict key to be string literal')
TYPEVAR_BOUND_MUST_BE_TYPE: str = (source)

Undocumented

Value
'TypeVar "bound" must be a type'
TYPEVAR_UNEXPECTED_ARGUMENT: str = (source)

Undocumented

Value
'Unexpected argument to "TypeVar()"'
TYPEVAR_VARIANCE_DEF: str = (source)

Undocumented

Value
'TypeVar "{}" may only be a literal bool'
UNSUPPORTED_ARG_1_FOR_SUPER = (source)

Undocumented

Value
ErrorMessage('Unsupported argument 1 for "super"')
UNSUPPORTED_ARG_2_FOR_SUPER = (source)

Undocumented

Value
ErrorMessage('Unsupported argument 2 for "super"')
YIELD_VALUE_EXPECTED = (source)

Undocumented

Value
ErrorMessage('Yield value expected')