Reputation: 527
I'm manually creating a pyi file for one of my classes and one of its function return types relies on an enum I made in another file.
Relevant code snippets: Board.pyi
class Board:
def access(self, i: int, j: int) -> Color: ...
Where Color
is the enum. To resolve the fact that Color
is not defined in the pyi file, should I just import it from Color.py
/ Color.pyi
or is there another solution that's detailed by PEP?
Upvotes: -1
Views: 615
Reputation: 447
You can use a normal import
statement to bring in any types you need in your .pyi
file. The official type stub documentation has this as an example:
from typing_extensions import Literal
def foo(x: Literal[""]) -> int: ...
Upvotes: -1