Skip to content

Commit c29ccd4

Browse files
committed
Avoid error for creating underscore object
Don't show an error about calling a function named '_' directly when '_' refers to a class named '_' and we're actually creating an object. Having a class named '_' is probably rare and using it directly is probably even rarer, but the other parts of the PR only deal with functions, not classes, so we probably should keep that consistent.
1 parent 65df17c commit c29ccd4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mypy/checkexpr.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,9 @@ def visit_call_expr_inner(self, e: CallExpr, allow_none_return: bool = False) ->
334334
and callee_type.implicit):
335335
self.msg.untyped_function_call(callee_type, e)
336336

337-
if isinstance(callee_type, CallableType) and callee_type.name == "_":
337+
if (isinstance(callee_type, CallableType)
338+
and not callee_type.is_type_obj()
339+
and callee_type.name == "_"):
338340
self.msg.underscore_function_call(e)
339341
return AnyType(TypeOfAny.from_error)
340342

0 commit comments

Comments
 (0)