Skip to content

Provide a FloatInt (float | int) type alias #181

Description

@llucax

Summary

Please provide frequenz.core.FloatInt, defined as the honest alias float | int.

Motivation

PEP 484 numeric tower permits an int wherever a float annotation is
expected. A value annotated only as float can therefore be an int at
runtime: isinstance(1, float) is false, case float() does not match it,
and float-only methods such as hex() are unavailable. The float | int
alias makes that runtime heterogeneity explicit to consumers and type checkers.

Current downstream home and compatibility

frequenz-client-common currently defines FloatInt as float | int. Its rationale and rejected alternatives are recorded in frequenz-client-common-python#250.

If core provides this alias, client-common would re-export the core type and
deprecate its local definition in favor of frequenz.core.FloatInt, retaining
a compatible migration path for existing consumers.

Metadata

Metadata

Assignees

Labels

type:enhancementNew feature or enhancement visitble to users

Fields

Priority

High

Effort

Low

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions