Skip to content

Does not recognize __func__ of methods #14123

Open
@asottile-sentry

Description

@asottile-sentry

seems similar to #2563, #3482, #8869, #11211, #12673 -- though those are mostly about decorated descriptors

Bug Report

simple, silly example:

class C:
    def f(self) -> None: pass

    def g(self) -> None:
        print(self.f.__func__)

C().g()

Expected Behavior

no error

Actual Behavior

$ ./.venv/bin/mypy t.py
t.py:5: error: "Callable[[], None]" has no attribute "__func__"  [attr-defined]
Found 1 error in 1 file (checked 1 source file)
$ ./.venv/bin/mypy --version
mypy 0.991 (compiled: yes)

Your Environment

  • Mypy version used: 0.991
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.8.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-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