Skip to content

Error with methods defined as function references wrapped in staticmethod()  #5530

Closed
@jleclanche

Description

@jleclanche
def foo(key: str) -> str:
	return key


class A:
	@staticmethod
	def foobar(key: str) -> str:
		return "hello world"


class B(A):
	foobar = staticmethod(foo)

This yields the following error on B.foobar:

error:Incompatible types in assignment (expression has type "staticmethod", base class "A" defined the type as "Callable[[str], str]")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions