3 ms·
import numpy as np def f(x:numpy.array): pass Since numpy doesn’t exist in my namespace I get a runtime error (NameError) for a part of my code th
by wodenokoto 6y ago
import numpy as np
def f(x:numpy.array):
pass
Since numpy doesn’t exist in my namespace I get a runtime error (NameError) for a part of my code that supposedly isn’t used.
I just feel like this should throw errors when running mypy and not when running my script.
- kjagiello 6y agohttps://www.python.org/dev/peps/pep-0563/ https://www.python.org/dev/peps/pep-0563/
- BerislavLopac 6y agoThis is exactly what happens starting with Python 3.7, which implements PEP 563 [0]; you just need to enable it by importing annotations from __future__. Starting from Python 3.10 that will be the default. [0] [0] https://docs.python.org/3/whatsnew/3.7.html#pep-563-postponed-evaluation-of-annotations https://docs.python.org/3/whatsnew/3.7.html#pep-563-postpone...