How to import .pyd file without red line

1.4k views Asked by At

enter image description here

enter image description here

I can use the pyd file to get a correct answer, but the pyd file never get me the code hinting and there is a red line in pycharm. I don't know how to solve this question.

1

There are 1 answers

0
Ahmed AEK On

the only method i know is to create another file named MH.pyi (the same name as the .pyd except only .pyi)

and for every function in the .pyd file, create a similar function in the .pyi file that is empty.

def function1(arg1,arg2,arg3):
    """some function documentation"""
    pass

at runtime, python will run your .pyd file, but all code editors will be able to open the .pyi file to get information from it (like documentation and argument types, and return types if you specify them, etc).