Skip to content

Conversation

@Avasam
Copy link
Contributor

@Avasam Avasam commented Apr 3, 2025

Reduce changes from #343

Technically a user-facing change, but not sure how to present that in a changelog for setuptools, considering the changelog entry "Always return an actual bool from has_* functions" wouldn't apply to all setuptools' own methods.

@Avasam Avasam force-pushed the Always-return-an-actual-`bool`-from-``has_-``-functions branch from b30cd49 to 02c74f2 Compare May 3, 2025 15:04
@jaraco jaraco merged commit b2beb1c into pypa:main May 4, 2025
20 checks passed
@Avasam Avasam deleted the Always-return-an-actual-`bool`-from-``has_-``-functions branch May 4, 2025 13:53
@jaraco
Copy link
Member

jaraco commented May 4, 2025

After reflecting on this change for a bit, I realized I don't want to apply this technique generally.

One of the nice things about Python is the ability to use the boolean inference to make checks on objects that aren't themselves boolean. It's nice not to have to write if bool(list_obj) and just write if list_obj. I'd like to see the type checkers start supporting a SupportsBool protocol or similar... or allow any object to be used in place of a bool.

I'm guessing the typechecker authors have already considered this problem and realized that since Any python object can be treated as a boolean, there's little strictness in allowing a declared 'bool' to resolve from Any.

I do want to try avoid sprinkling bool() all over the place simply because the typecheckers are being nitpicky. The simple elegance of boolean inference would be lost, so I'll be resistant to changes like these in the future.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants