Skip to content

Conversation

@tannguyencse19
Copy link
Contributor

Summary

Fix assert callable(x) narrowing because callability does not imply an object return type

Fixes #911

Test Plan

cargo test test_assert_callable_narrow_any
cargo test test_builtins_callable_narrow

@meta-cla meta-cla bot added the cla signed label Dec 28, 2025
@yangdanny97 yangdanny97 self-assigned this Dec 29, 2025
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.

We can't fix this by changing the bundled typeshed stubs, the source of truth is in https://github.com/python/typeshed so they'll get overwritten the next time we pull them

We can either:

  1. Make a PR to the typeshed repo
  2. Special-case builtins.callable(...) narrowing behavior just like we do for issubclass, isinstance, etc.

@tannguyencse19
Copy link
Contributor Author

@yangdanny97 I haven't think that way. Let me take a look

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.

assert callable narrows too much

2 participants