Skip to content

How to type hint a "float-like" object? #2038

Discussion options

You must be logged in to vote

You might want to use a protocol with a __pow__ method (since the ** operator calls __pow__). Search for typing.Protocol for more. There are many things "float-like" could mean but a Protocol should generally be able to express them.

Replies: 5 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by srittau
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
topic: other Other topics not covered
4 participants
Converted from issue

This discussion was converted from issue #2037 on July 02, 2025 10:55.