Skip to content

Class is not compatible with protocol because some method should be an instance method but it's a static method #498

@bersbersbers

Description

@bersbersbers

Things to check first

  • I have searched the existing issues and didn't find my bug already reported there

  • I have checked that my bug is still present in the latest release

Typeguard version

4.4.0

Python version

3.13.0

What happened?

Typeguard says that

typeguard.TypeCheckError: argument "arg" (class code.Class) is not compatible with the Proto protocol because its 'method' method should be an instance method but it's a static method

I think it is wrong saying that.

How can we reproduce the bug?

bug.py

from typeguard import install_import_hook

install_import_hook()

from code import Class, function

function(Class)

code.py

from typing import Protocol


class Proto(Protocol):
    def method(self): ...


class Class(Proto):
    def method(self): ...


def function(arg: type[Proto]): ...

Then run python bug.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions