← Back to index

specialtypes_promotions.py

True Positive
False Positive
False Negative
Optional (detected)
Warning or Info
TP: 1
FP: 0
FN: 0
Optional: 0 / 0
1"""
2Tests "type promotions" for float and complex when they appear in annotations.
3"""
4
5# Specification: https://typing.readthedocs.io/en/latest/spec/special-types.html#special-cases-for-float-and-complex
6
7v1: float = 1
8v2: complex = 1.2
9v2 = 1
12def func1(f: float):
13 f.numerator # E
[unresolved-attribute] Attribute `numerator` is not defined on `float` in union `int | float`
15 if not isinstance(f, float):
16 f.numerator # OK