Skip to content

recognize staticmethod's __func__ #11211

Open
@kcwu

Description

@kcwu

To Reproduce

Run mypy against this code

class A(object):
    @staticmethod
    def open():
        return 123
    @staticmethod
    def proccess():
        return 456

    switch = {
        1: open.__func__,
        2: proccess.__func__,   
    }

p.s. this code snippet is copied from the first solution of https://stackoverflow.com/questions/41921255/staticmethod-object-is-not-callable

Expected Behavior

This code snippet should pass mypy's check.

Actual Behavior

s.py:10: error: "Callable[[], Any]" has no attribute "__func__"
s.py:11: error: "Callable[[], Any]" has no attribute "__func__"
Found 2 errors in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 0.910
  • Mypy command-line flags: just file name
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.9.7
  • Operating system and version: Debian rodete

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-descriptorsProperties, class vs. instance attributestopic-runtime-semanticsmypy doesn't model runtime semantics correctly

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions