← 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
"""
2
Tests
"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
7
v1
:
float
=
1
8
v2
:
complex
=
1.2
9
v2
=
1
10
11
12
def
func1
(
f
:
float
):
13
f
.
numerator
# E
[unresolved-attribute] Attribute `numerator` is not defined on `float` in union `int | float`
14
15
if
not
isinstance
(
f
,
float
):
16
f
.
numerator
# OK