8000 Inline staticmethod assignment on subclass fails with `Incompatible types in assignment` · Issue #4574 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content
8000
Inline staticmethod assignment on subclass fails with Incompatible types in assignment #4574
Closed as not planned
@momandine

Description

@momandine

A simplification of some old code I am trying to add mypy to:

class Base(object):
    def foo(self):
         # type: () -> None
         a = self.static_foo()

class SubClass(Base):
    static_foo = staticmethod(lambda: 5)

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

Oddly, as far as I can tell, static_foo is not actually defined on the base class.

This is using Dropbox's mypy setup, with --strict-optional. I am actually not sure which version we're on, but can look it up and edit this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-descriptorsProperties, class vs. instance attributes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0