Skip to content

bad-argument-type - false negative when calling decorator function with wrong type #5536

Open

Description

@DetachHead

Describe the Bug

def deco(cls: int) -> int:
    return cls


@deco # no error
class Baz: ...

ty and pyright catch this

Sandbox Link

https://pyrefly.org/sandbox/?project=v2.w1VkgqIwJTU5XyM5B5iLgOEKjkogbRUDzWDQ5AGUB4nAsANIk4KyQl4-JBRBYpBs55RYZaWgp6cHEiE27ExBXi0oSi1OLQELAaMgBr9_AA

(Only applicable for extension issues) IDE Information

No response

Activity

  1. changed the title [-]no error when calling decorator function with wrong type[/-] [+]`bad-argument-type` - false negative when calling decorator function with wrong type[/+] on Nov 5, 2026
  2. DetachHead commented on Nov 5, 2026

    @DetachHead
    ContributorAuthor

    it works when calling the function normally:

    def deco(cls: int) -> int: ...
    
    
    class Baz: ...
    
    deco(Baz) # error: Argument `type[Baz]` is not assignable to parameter `cls` with type `int` in function `deco` [bad-argument-type]

    pyright and mypy have had similar issues in the past, caused by the fact that they also use different logic for checking decorator calls for some reason. ideally it should use the same logic used for checking a regular function call to avoid issues like this.

  3. added theissue type on Nov 5, 2026
  4. rchen152 commented on Nov 5, 2026

    @rchen152
    Contributor

    Likely related: #1180

  5. self-assigned this
    on Nov 5, 2026
  6. connernilsen commented on Nov 5, 2026

    @connernilsen
    Contributor

    Yeah, I think #2294 (PR for #1180) may fix this, but will keep an eye on it to make sure once it's landed

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

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions