Skip to content

Conversation

@fangyi-zhou
Copy link
Contributor

@fangyi-zhou fangyi-zhou commented Jan 2, 2026

Summary

There are some properties on builtin.type that cannot be resolved (e.g. __mro__).

@property
def __mro__(self) -> tuple[type, ...]: ...

This is due to attribute lookup used for type not handing properties (since attr.as_instance_method() is used).

This diff adds calls to call_property_getter for a proper property resolution. Since builtin types are bundled in typeshed, we can expect the types to be correct, so we can use an error swallower.

Make 3 more conformance tests pass.

Test Plan

python test.py

@meta-cla meta-cla bot added the cla signed label Jan 2, 2026
There are some properties on `builtin.type` that cannot be resolved
(e.g. `__mro__`). This is due to attribute lookup used for `type` not
handing properties (since `attr.as_instance_method()` is used).

This diff implements a hacky workaround. The reason is that we don't
have all the arguments to call `call_property_getter` for a proper
property resolution. Since builtin types are bundled in typeshed, we can
expect the types to be correct, so we use the return type in the
property getter.

Make 3 more conformance tests pass.
@github-actions
Copy link

github-actions bot commented Jan 2, 2026

Diff from mypy_primer, showing the effect of this PR on open source code:

discord.py (https://github.com/Rapptz/discord.py)
+ ERROR discord/utils.py:743:24-37: Object of class `type` has no attribute `__slots__` [missing-attribute]

@kinto0 kinto0 self-assigned this Jan 5, 2026
@meta-codesync
Copy link

meta-codesync bot commented Jan 5, 2026

@kinto0 has imported this pull request. If you are a Meta employee, you can view this in D90122359.

Copy link
Contributor

@yangdanny97 yangdanny97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@meta-codesync
Copy link

meta-codesync bot commented Jan 5, 2026

@kinto0 merged this pull request in 7197ac6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants