-
Notifications
You must be signed in to change notification settings - Fork 284
Closed
Labels
topic: featureDiscussions about new features for Python's type annotationsDiscussions about new features for Python's type annotations
Description
It's not clear what's the best way to deal with numbers.Integral, numbers.Real, etc. Various issues are discussed in python/typeshed#464.
Some relevant questions:
- Should
intbe a subclass ofIntegral(and similarly forfloat/Real)? If yes, how should we annotate the stubs? (Let's focus on__add__and__radd__-- other operators are probably similar.) - Should stubs prefer
IntegralandRealtointandfloatwhenever feasible? Many stdlib functions only accept concreteintorfloatinstances, so using them everywhere wouldn't be safe. - Should we recommend user code to use
intorIntegralby default? If we don't have a consistent convention, integrating codebases that use different conventions could become painful, asIntegralshould almost certainly not be a subtype ofint. - Can we find examples of some typical use cases where just using
int/floatis not sufficient andIntegral/Realcould help? How common and important are these use cases? - If (1) is blocked by limitations of the type system, should we look at extending to the type system to better support abstract numeric types? What are the current limitations?
- If (1) or (2) requires compromising some type safety, are the gains important enough to make this a worthwhile tradeoff?
Metadata
Metadata
Assignees
Labels
topic: featureDiscussions about new features for Python's type annotationsDiscussions about new features for Python's type annotations