Skip to content

--disallow-untyped-calls reports errors in untyped functions #12912

Open
@pranavrajpal

Description

@pranavrajpal

Bug Report

Using --disallow-untyped-calls and --check-untyped-defs results in errors about calling untyped functions in a typed context, even when calling from an untyped function.

To Reproduce

Test case:

[case testDisallowUntypedCallsFromUntypedFunction]
# flags: --disallow-untyped-calls --check-untyped-defs

def f(x):
    pass

def g(y):
    f(y)

Expected Behavior

Either:

  • the documentation and the error message should be updated to specify that --disallow-untyped-calls disallows all calls to untyped functions, regardless of whether the current function has type annotations, or
  • the above code shouldn't produce any errors

Actual Behavior

The call to f in the above example produces the error "Call to untyped function "f" in typed context".

Your Environment

See https://mypy-play.net/?mypy=latest&python=3.10&flags=check-untyped-defs%2Cdisallow-untyped-calls&gist=3350fe27968b29dabc5ef1e207d008ce to reproduce.

This came up in #12901 (specifically the mypy_primer diff had an error here)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions