Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions mypy/checkexpr.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Expression type checker. This file is conceptually part of TypeChecker."""

from mypy.util import unnamed_function
from mypy.backports import OrderedDict, nullcontext
from contextlib import contextmanager
import itertools
Expand Down Expand Up @@ -347,12 +346,6 @@ def visit_call_expr_inner(self, e: CallExpr, allow_none_return: bool = False) ->
and callee_type.implicit):
self.msg.untyped_function_call(callee_type, e)

if (isinstance(callee_type, CallableType)
and not callee_type.is_type_obj()
and unnamed_function(callee_type.name)):
self.msg.underscore_function_call(e)
return AnyType(TypeOfAny.from_error)

# Figure out the full name of the callee for plugin lookup.
object_type = None
member = None
Expand Down
6 changes: 6 additions & 0 deletions test-data/unit/check-functions.test
Original file line number Diff line number Diff line change
Expand Up @@ -2230,6 +2230,12 @@ reveal_type(h) # N: Revealed type is "builtins.function"
h(7) # E: Cannot call function of unknown type
[builtins fixtures/bool.pyi]

[case testFunctionWithNameUnderscore]
def _(x: int) -> None: pass

_(1)
_('x') # E: Argument 1 to "_" has incompatible type "str"; expected "int"

-- Positional-only arguments
-- -------------------------

Expand Down
3 changes: 2 additions & 1 deletion test-data/unit/check-redefine.test
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ def _(arg: str):
def _(arg: int) -> int:
return 'a' # E: Incompatible return value type (got "str", expected "int")

[case testCallingUnderscoreFunctionIsNotAllowed]
[case testCallingUnderscoreFunctionIsNotAllowed-skip]
# Skipped because of https://github.com/python/mypy/issues/11774
def _(arg: str) -> None:
pass

Expand Down