[Python] MyPy: Can not suppress [no-untyped-call]

Discussão em 'Python' iniciado por Stack, Dezembro 21, 2024.

  1. Stack

    Stack Membro Participativo

    I have been using MyPy python type analysis, I am trying to ignore a specific type warning,

    Here is my mypy.ini

    [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


    Here is my sample py code,

    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())


    When I run the mypy like below,

    mypy --config-file mypy.ini tests/experiments/py_templ.py


    I get following output

    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)


    But, in the ini file , I allow allow_untyped_calls , Why MyPy still complains?

    In general I could not get the scoping of the MyPy.ini specification. Please help.

    Continue reading...

Compartilhe esta Página