I think i
in .pyi
means "Interface"
Definition for an interface in Java :
An interface in the Java programming language is an abstract type that is used to define the behavior that classes should implement.
Each Python module is represented by a .pyi
. This is a regular Python file (i.e., it can be interpreted by Python 3), except that all methods are empty .
- In the Mypy repository , they explicitly mention stubs as public interfaces:
The stub file contains only a description of the open interface of the module without any implementations.
Since “Interfaces” do not exist in Python (see this SO question between the Abstract and Interface class ), I think the designers intended to provide a special extension for it.
pyi
implements a stub file (definition from Martin Fowler )
Stubs : Provide constant answers to calls made during the test, usually not responding at all, except for what is programmed for the test.
But people are more familiar with interfaces than with stubs, so it was easier to choose .pyi
than .pys
to avoid unnecessary confusion.
source share