Do @overloads require an implementation in .pyi stubs ? #1838
-
When using Is this also the case for a .pyi file, or can the implementation be omitted ? # Pin.pyi
# No overloading
class Pin_naive:
def __init__(self, number: int) -> None:
self.number = number
def value(self, x: Optional[Any] = None) -> int:
"""
This method allows to set and get the value of the pin, depending on whether
the argument ``x`` is supplied or not.
"""
...
# Overload for get and set
class Pin:
def __init__(self, number: int) -> None:
self.number = number
@overload
def value(self, x: bool | int ) -> None:
"""Set output state of the pin."""
@overload
def value(self, x: None ) -> int:
"""Get the value of the pin"""
...
def value(self, x: Optional[Any] = None) -> int:
"""
Is this implementation required in a .pyi file ?.
"""
...
|
Beta Was this translation helpful? Give feedback.
Answered by
JelleZijlstra
Aug 10, 2024
Replies: 1 comment 2 replies
-
No, the implementation is not required in |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The PEP is no longer normative. The current spec is https://typing.readthedocs.io/en/latest/spec/overload.html and it says pretty clearly that the implementation is required only in .py files.