Skip to content

Can't get FunctionType #22502

Open
Open

Description

@zedzhen

Bug Report

Initially, the problem arose when using the overloaded package.

pyright, ty, pyrefly have not warnings.

To Reproduce

from types import FunctionType


def dec(func: FunctionType) -> FunctionType:
    return func


@dec
def f() -> None:
    pass

Expected Behavior

no warning

Actual Behavior

:8: error: Argument 1 to "dec" has incompatible type "Callable[[], None]"; expected "FunctionType" [arg-type]

Your Environment

  • Mypy version used: mypy 2.4.1 (compiled: yes)
  • Mypy command-line flags: no
  • Mypy configuration options from mypy.ini (and other config files): no
  • Python version used: 3.14.10

Activity

  1. zhengdaodeguL commented on Nov 17, 2026

    @zhengdaodeguL

    Fixed in #22503: functions use builtins.function as their fallback, which is the same runtime type as types.FunctionType, so the subtype check in mypy/subtypes.py now treats it as a subtype. The repro now reports no issues, and passing a non-function (e.g. int) is still rejected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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