microsoft / microsoft/pyright

1.1.408 regression: class instances with a custom metaclass are treated as types

Open
#11,548 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
15.6k
Forks
1.8k
Avg merge
12h 13m
Merged PRs (30d)
52

Description

Code sample in [pyright playground](https://pyright-play.net/?code=MYGwhgzhAECyCmAXMAKRBPADvAlALgChpjpNIICDRzoBBFAWyTGqgF4Fl9iBiaAJXgMA9gDd40JslYxEw6MIBGEeACdx0RAAsJwYatXxgiaIvhawogJb6iJMlEoATeADNorgK4A7YCjB4dPh2vNAAKjrQAObCctAurlbeVog23tBgIBDyMfCy8hjYAHQA%2BiVOVsZlADTQ3rEKigBWRoil5ZWIZSHQhuKZJYXw-u0VVSU4obBgmJhJUQAKqsIAHuhhWPAA2hCIqrW03ugAutAA7ilakswytWOIO3sHR6cX2sKeiARAA)

```python
class Meta(type):
pass

class A(metaclass=Meta): # Remove metaclass to observe the correct behavior
pass

def func(a: A):
# The goto definition also goes to type.__dict__, not object.__dict__
reveal_type(a.__dict__) # MappingProxyType[str, Any] with metaclass, dict[str, Any] without
```

Contributor guide

Open the contributing guide

Research direction

Start with the linked Pyright playground example and reproduce the different reveal_type results with and without the custom metaclass. Trace how Pyright resolves __dict__ and goto definition for class instances, then verify that the custom-metaclass case matches the expected instance behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.