pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

operator.truth doesn't narrow type, but bool does

Open hunterhogan opened this issue 3 days ago • 2 comments

Describe the Bug

.. function:: truth(obj)


   Return :const:`True` if *obj* is true, and :const:`False` otherwise.  This is
   equivalent to using the :class:`bool` constructor.

CPython

Code block?

https://github.com/pyrefly-org/pyrefly/blob/34f240e95bceceb614b99fdb8de9f2b3d5a1b372/pyrefly/lib/binding/narrow.rs#L1271-L1286

Sandbox Link

https://pyrefly.org/sandbox/?project=v2.pZQ9CsMwDIWvYsjgTtXesSfoAby4rYmz2CFRQo_fJ_8UQsEJZLSQhKX36TUtM47ZGurN87Swr5iug73jgC_sPpzurhCaNMcTqzIMWZ81SdgybLhwJSEJlCeGwli_1hCO_W7v9KHDzf8V69QjB1QZHl4FqfsFY0PCqwkdzNApzzzON6JaHqeeXKB3fM20qSAlcNrVDslnt-2wz-zIJpxBRWdSdAsULZwgo6n9Fw

(Only applicable for extension issues) IDE Information

No response

hunterhogan avatar Nov 29 '26 15:11 hunterhogan

#claim

Quaden2307 avatar Nov 29 '26 18:11 Quaden2307

@Quaden2307 you've claimed this issue — it's now assigned to you. Thanks for picking it up! 🎉

github-actions[bot] avatar Nov 29 '26 18:11 github-actions[bot]