Ich habe eine Analyse von MyPy Python-Typ verwendet. Ich versuche, eine bestimmte Typwarnung zu ignorieren, < /p>
Hier ist mein mypy.ini < /p>
[mypy]
python_version = 3.9
# Needed because of bug in MyPy
disallow_subclassing_any = False
# Options to make the checking stricter.
check_untyped_defs = True
disallow_untyped_defs = True
disallow_untyped_calls = True
#Plugins
plugins = numpy.typing.mypy_plugin
[mypy-numpy.*]
allow_untyped_defs = True
allow_untyped_calls = True
implicit_reexport = True
< /code>
Hier ist mein Beispielpy-Code, < /p>
import numpy as np
import numpy.typing as npt
def test() -> npt.NDArray[np.float32]:
distance_win: npt.NDArray[np.float32] = np.kron(
np.ones((10, 1))
, np.ones((10, 1))
)
print (distance_win)
return distance_win
if __name__ == '__main__':
print (test())
< /code>
Wenn ich die MyPy wie unten ausführe, < /p>
mypy --config-file mypy.ini tests/experiments/py_templ.py
< /code>
Ich erhalte die folgende Ausgabe < /p>
tests\experiments\py_templ.py:32: error: Call to untyped function "kron" in typed context [no-untyped-call]
Found 1 error in 1 file (checked 1 source file)
< /code>
Aber in der INI -Datei erlaube ich erlaubte_untyped_calls, warum mypy immer noch beschwert? Bitte helfen Sie.
MyPy: Kann [nicht untypisch] nicht unterdrücken] ⇐ Python
-
- Similar Topics
- Replies
- Views
- Last post