[Python] How to make pylance recognize type stubs

Discussão em 'Python' iniciado por Stack, Março 9, 2025.

  1. Stack

    Stack Membro Participativo

    I have written a python library with strict typing. It uses a devcontainer, and is setup with pre-commit conditions including mypy. Everything works fine, and I've used this workflow on many projects.

    But if i try to activate typing with pylance can not recognize the pyi files in the same folder with the same name [​IMG]

    #test.pyi
    def myfunc(arg1: str, arg2: str) -> str: ...


    #test.py
    def myfunc(arg1, arg2):
    return arg1 + arg2



    [​IMG]

    Ive never had the combination of .pyi files and pylance strict type checking before, using one but not the other works, but having them together don't. I do not understand why.

    Tried using pyrightconfig, stubs folder, typing folder etc. Nothing leads anywhere :( Tried checking around on forums, here, but seems like no one else have had this issue? Does anyone have any usable example guides on how to use typestubs with pylance typechecking?

    Continue reading...

Compartilhe esta Página