Skip to content

bad-argument-type false positive in an untyped classmethod with *args #2605

@superbobry

Description

@superbobry

Describe the Bug

Reproducer:

class A:
  @classmethod
  def create(*args, **kwargs): ...


A.create(42)

Output:

ERROR Argument `Literal[42]` is not assignable to parameter `*args` with type `type[A]` in function `A.create` [bad-argument-type]
 --> /tmp/foo.py:6:10
  |
6 | A.create(42)
  |          ^^
  |

Note that the first parameter of create is already bound by the time we type check the call. So, it seems confusing to type check 42 as if it is going to be bound to the cls parameter.

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions