-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let SupportsDunderLT
return SupportsBool
instead of bool
.
#12939
base: main
Are you sure you want to change the base?
Let SupportsDunderLT
return SupportsBool
instead of bool
.
#12939
Conversation
ac2cabd
to
a4059c2
Compare
This comment has been minimized.
This comment has been minimized.
SupportsDunderLT
return SupportsBool
instead of bool
.
Even though this technically doesn't cover all cases, I like this "explicit is better than implicit" approach, and I'm a big fan of structural typing solutions like these 👌🏻. |
self is considered positional-only by type checkers as far as I am aware of
python/typing#1355
…On Fri, 1 Nov 2024, 15:45 Joren Hammudoglu, ***@***.***> wrote:
Even though this technically doesn't cover all cases, I like this
"explicit is better than implicit" approach, and I'm a big fan of
structural typing solutions like these 👌🏻.
—
Reply to this email directly, view it on GitHub
<#12939 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJO3RGFNL23MLRPRRWMDBU3Z6OHY5AVCNFSM6AAAAABRAJIIOOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJRHE4TKNBYGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@randolf-scholz ahh good to know 👍🏻 |
This comment has been minimized.
This comment has been minimized.
Ibis can easily fix the issue by adding |
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: ibis (https://github.com/ibis-project/ibis)
- ibis/expr/types/relations.py:2924: error: Value of type variable "SupportsRichComparisonT" of "sorted" cannot be "NumericValue | float" [type-var]
jax (https://github.com/google/jax)
+ jax/_src/pallas/mosaic/pipeline.py:981: error: Unused "type: ignore" comment [unused-ignore]
|
Fixes #12562, alternative to #12573. Introduces a new protocol in
_typeshed/__init__.pyi
Changes
SupportsDunderLT
and variants to returnSupportsBool
instead ofbool
.Note that an earlier comment by JelleZijlstra suggested that
SupportsBool
is equivalent toobject
in practice. This does not seem to quite be the case: Code sample in pyright playgroundIndeed, despite the documentation mentioning
object.__bool__
, this method is not defined onobject
. Rather, the truthiness of an object is defined roughly like: