Skip to content

isinstance with self.__class__ infers 'object' as the type #3061

Closed
@JukkaL

Description

@JukkaL

An unexpected type is revealed by this program:

from typing import Any

class A:
    def f(self, o: Any) -> None:
        isinstance(o, self.__class__) and reveal_type(o)  # Revealed type is 'builtins.object'

The issue was introduced by #2997. The most precise type would be A. Mypy used to infer Any as the type before #2997.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions