diff --git a/astroid/brain/brain_builtin_inference.py b/astroid/brain/brain_builtin_inference.py index a56b1525c..9ab7b8b23 100644 --- a/astroid/brain/brain_builtin_inference.py +++ b/astroid/brain/brain_builtin_inference.py @@ -769,7 +769,9 @@ def infer_issubclass(callnode, context: InferenceContext | None = None): except (InferenceError, StopIteration) as exc: raise UseInferenceDefault from exc if not isinstance(obj_type, nodes.ClassDef): - raise UseInferenceDefault("TypeError: arg 1 must be class") + raise UseInferenceDefault( + f"TypeError: arg 1 must be class, not {type(obj_type)!r}" + ) # The right hand argument is the class(es) that the given # object is to be checked against. diff --git a/astroid/brain/brain_namedtuple_enum.py b/astroid/brain/brain_namedtuple_enum.py index 104bd9764..2cbb17097 100644 --- a/astroid/brain/brain_namedtuple_enum.py +++ b/astroid/brain/brain_namedtuple_enum.py @@ -280,7 +280,9 @@ def _check_namedtuple_attributes(typename, attributes, rename=False): # for name in (typename, *attributes): if not isinstance(name, str): - raise AstroidTypeError("Type names and field names must be strings") + raise AstroidTypeError( + f"Type names and field names must be strings, not {type(name)!r}" + ) if not name.isidentifier(): raise AstroidValueError( "Type names and field names must be valid" + f"identifiers: {name!r}" diff --git a/astroid/helpers.py b/astroid/helpers.py index 62a72595e..360c1ae90 100644 --- a/astroid/helpers.py +++ b/astroid/helpers.py @@ -129,7 +129,9 @@ def _object_type_is_subclass( # issubclass(object, (1, type)) raises TypeError for klass in class_seq: if isinstance(klass, util.UninferableBase): - raise AstroidTypeError("arg 2 must be a type or tuple of types") + raise AstroidTypeError( + f"arg 2 must be a type or tuple of types, not {type(klass)!r}" + ) for obj_subclass in obj_type.mro(): if obj_subclass == klass: @@ -164,7 +166,7 @@ def object_issubclass( or its type's mro doesn't work """ if not isinstance(node, nodes.ClassDef): - raise TypeError(f"{node} needs to be a ClassDef node") + raise TypeError(f"{node} needs to be a ClassDef node, not {type(node)!r}") return _object_type_is_subclass(node, class_or_seq, context=context) diff --git a/astroid/protocols.py b/astroid/protocols.py index 7cc50810f..387f9f8ac 100644 --- a/astroid/protocols.py +++ b/astroid/protocols.py @@ -809,7 +809,7 @@ def _determine_starred_iteration_lookups( if not isinstance(target, nodes.Tuple): raise InferenceError( - "Could not make sense of this, the target must be a tuple", + f"Could not make sense of this, the target must be a tuple, not {type(target)!r}", context=context, )