Skip to content

Attribute access with untyped methods and --check-untyped-defs #5401

@srittau

Description

@srittau

Using mypy 0.620 and Python 3.7.0 I see strange behavior with descriptors in untyped methods. For example:

from typing import Any

class Getter:
    def __get__(self, obj: Any, _: Any = None) -> int:
        return 4

class Foo:
    x = Getter()

    def foo(self):
        reveal_type(self.x)

    def bar(self) -> None:
        reveal_type(self.x)

Running with mypy --check-untyped-defs I get the following output:

foo.py:11: error: Revealed type is 'Any'
foo.py:14: error: Revealed type is 'builtins.int'

Is this intended?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy