I am new to Python's static typing module mypy. I am trying to append ints and floats to an array, which I typed statically to be Real. But mypy says that they are incompatible types with Real. I thought ints and floats are a subtype of Real?
from typing import List
from numbers import Real
data : List[Real] = []
with open(path, 'r') as file:
for line in file:
line = line.strip()
if subject == 'time':
data.append(float(line))
else:
data.append(int(line))
Error message:
graph.py:56: error: Argument 1 to "append" of "list" has incompatible type "float"; expected "Real"
graph.py:58: error: Argument 1 to "append" of "list" has incompatible type "int"; expected "Real"