Skip to content

Commit

Permalink
Merge pull request #282 from ska-sa/typing-send-udp-stream
Browse files Browse the repository at this point in the history
Fix type annotations for send.UdpStream constructors
  • Loading branch information
bmerry authored Sep 22, 2023
2 parents 36b2fb7 + 593da22 commit aca07e2
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions src/spead2/send/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,28 @@ class SyncStream(Stream):
class _UdpStream:
DEFAULT_BUFFER_SIZE: ClassVar[int]

# There are a lot of overloads listed here, because the bindings have
# overloads where required arguments follow optional arguments, and that
# can't be represented in pure Python. So we have to distinguish the
# cases where the required arguments are specified by name versus
# position.
@overload
def __init__(
self,
thread_pool: spead2.ThreadPool,
socket: socket.socket,
hostname: str,
port: int,
endpoints: _EndpointList,
config: StreamConfig = ...,
buffer_size: int = ...,
interface_address: str = ...,
) -> None: ...
@overload
def __init__(
self,
thread_pool: spead2.ThreadPool,
endpoints: _EndpointList,
config: StreamConfig,
buffer_size: int,
ttl: int,
) -> None: ...
@overload
def __init__(
Expand All @@ -114,7 +128,8 @@ class _UdpStream:
endpoints: _EndpointList,
config: StreamConfig = ...,
buffer_size: int = ...,
interface_address: str = ...,
*,
ttl: int,
) -> None: ...
@overload
def __init__(
Expand All @@ -124,13 +139,16 @@ class _UdpStream:
config: StreamConfig,
buffer_size: int,
ttl: int,
interface_address: str,
) -> None: ...
@overload
def __init__(
self,
thread_pool: spead2.ThreadPool,
endpoints: _EndpointList,
config: StreamConfig,
config: StreamConfig = ...,
buffer_size: int = ...,
*,
ttl: int,
interface_address: str,
) -> None: ...
Expand All @@ -140,6 +158,18 @@ class _UdpStream:
thread_pool: spead2.ThreadPool,
endpoints: _EndpointList,
config: StreamConfig,
buffer_size: int,
ttl: int,
interface_index: int,
) -> None: ...
@overload
def __init__(
self,
thread_pool: spead2.ThreadPool,
endpoints: _EndpointList,
config: StreamConfig = ...,
buffer_size: int = ...,
*,
ttl: int,
interface_index: int,
) -> None: ...
Expand Down

0 comments on commit aca07e2

Please sign in to comment.