Skip to content

dmypy gives up on trivial decorator #18940

Open
@asottile-sentry

Description

@asottile-sentry

Bug Report

seems dmypy is unable to suggest an annotation when a function is decorated even with a trivial decorator (likely as the implementation predates widespread ParamSpec usage)

I believe the fix is deleting this line?

and isinstance(ct.arg_types[0], TypeVarType)

To Reproduce

from typing import Callable

def dec[R, **P](f: Callable[P, R]) -> Callable[P, R]:
    return f

@dec
def f():
    print('hello world')
[mypy]
check_untyped_defs = true

Expected Behavior

$ dmypy check .
...
$ dmypy suggest t.f
() -> None

Actual Behavior

$ dmypy check .
...
$ dmypy suggest t.f
Object t.f is a decorator we can't handle

Your Environment

  • Mypy version used: 1.15.0
  • Mypy command-line flags: (see above)
  • Mypy configuration options from mypy.ini (and other config files): (see above)
  • Python version used: 3.13.1

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions