specialtypes_promotions
error
Access to an int-only attribute on a float-typed parameter
The Python typing spec (PEP 484 / typing spec §Special cases for float and complex) states that int is not a subtype of float for static type-checking purposes. Attributes such as numerator and denominator are defined on int but NOT on float. Accessing them on a parameter declared as float is therefore a static type error.
The check is deliberately conservative — it only fires on **top-level** statements inside a function body, skipping any access inside an if/for/while/match/ with/try block. This means that accesses protected by an isinstance guard (where the parameter has been narrowed to int) are never flagged.
def func1(f: float):
f.numerator # E — float does not have .numerator
if not isinstance(f, float):
f.numerator # OK — narrowed to int inside the branch
How to handle it
Every rule is on by default — strict is the default, not a cage. You can dial
specialtypes_promotions down per-file or per-path from your editor or
pyproject.toml, or fix the code
so it type-checks. See the Type System rules and
the complete diagnostic reference.
Canonical URL: https://www.basilisk-python.dev/errors/specialtypes_promotions