Open hasii2011 opened 2 years ago
I'm also looking for stubs to this lib, but for pyright (which is used inside pylance).
I'm not very familiar with stubs rules, but I wrote a little __init__.pyi
to solve my problem for now, shown below.
But it does not cover the case of multiple interfaces implementation%3A).
For this particular case, I have to manually create the output of implements
and then create the implementation by multiple inheritance:
class I1(Interface):
def method1(self, x):
pass
class I2(Interface):
def method2(self, y):
pass
iI1, iI2 = implements(I1), implements(I2)
class ImplBoth(iI1,iI2):
...
For the other cases, this stub is working, so far.
__init__.pyi
from .default import default as default
from .interface import (implements as implements,
Interface as Interface,
InvalidImplementation as InvalidImplementation)
__all__ = [
"default",
"InvalidImplementation",
"Interface",
"implements",
]
from typing import TypeVar
InterfaceType = TypeVar("InterfaceType")
DefaultMethod = TypeVar("DefaultMethod")
class Interface: ...
def implements(interface: InterfaceType) -> InterfaceType: ...
def default(method: DefaultMethod) -> DefaultMethod:
"""Default implementation of a function in terms of interface methods."""
...
Do you have the above somewhere?