What is a PYI file?
A PYI file is a Python Interface Definition file that contains code stub reference for implementation of the interface. Each Python module is represented as a .pyi stub which is a normal Python file but with empty methods. The syntax of PYI files is the same as that of a regular Python module. The implementation of the empty methods is left for end-user to achieve specific objective for which the module is written. That is where PYI files are different than PY files which contain complete implementation of the program. PYI files can be opened with text editors such as Notepad, Notepad++, Microsoft Visual Studio Code, and JetBrains PyCharm.
PYI File Format
PYI files are saved as plain text files that can be opened with any text editor. Python is an interpreter language that performs type checking when the code is executed. In such case, PYI files are beneficial in the way that developers can manually define and check a module’s types while writing the application.