Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/netius/base/agent.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from typing import Any

from .observer import Observable
from .client import Client

class Agent(Observable):
@classmethod
def cleanup_s(cls) -> None: ...
def cleanup(self, destroy: bool = ...) -> None: ...
def destroy(self) -> None: ...

class ClientAgent(Agent):
_clients: dict[int, Client]

@classmethod
def cleanup_s(cls) -> None: ...
@classmethod
def get_client_s(cls, *args, **kwargs) -> Client: ...

class ServerAgent(Agent):
pass
32 changes: 32 additions & 0 deletions src/netius/base/client.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from typing import Any

from .common import Base, BaseThread

class Client(Base):
_client: "Client | None" = None

def __init__(self, thread: bool = ..., daemon: bool = ..., *args, **kwargs): ...
@classmethod
def get_client_s(cls, *args, **kwargs) -> "Client": ...
@classmethod
def cleanup_s(cls) -> None: ...
def ensure_loop(self, env: bool = ...) -> None: ...
def join(self, timeout: float | None = ...) -> None: ...
def connect(
self,
host: str,
port: int,
ssl: bool = ...,
key_file: str | None = ...,
cer_file: str | None = ...,
ca_file: str | None = ...,
ca_root: bool = ...,
ssl_verify: bool = ...,
family: int = ...,
type: int = ...,
ensure_loop: bool = ...,
env: bool = ...,
) -> bool: ...

class DatagramClient(Client):
def __init__(self, *args, **kwargs): ...
48 changes: 48 additions & 0 deletions src/netius/base/common.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from typing import Any, Callable, Iterable
import threading

class BaseThread(threading.Thread):
def __init__(
self, owner: Any | None = ..., daemon: bool = ..., *args, **kwargs
): ...
def run(self) -> None: ...

def new_loop_main(
factory: type | None = ..., env: bool = ..., _compat: bool | None = ..., **kwargs
) -> Any: ...
def new_loop_asyncio(**kwargs) -> Any | None: ...
def new_loop(
factory: type | None = ...,
_compat: bool | None = ...,
asyncio: bool | None = ...,
**kwargs
) -> Any: ...
def ensure_main(factory: type | None = ..., env: bool = ..., **kwargs) -> None: ...
def ensure_asyncio(**kwargs) -> Any | None: ...
def ensure_loop(
factory: type | None = ..., asyncio: bool | None = ..., **kwargs
) -> None: ...
def get_main(factory: type | None = ..., ensure: bool = ..., **kwargs) -> Any: ...
def get_loop(
factory: type | None = ...,
ensure: bool = ...,
_compat: bool | None = ...,
asyncio: bool | None = ...,
**kwargs
) -> Any: ...
def get_event_loop(*args, **kwargs) -> Any: ...
def stop_loop(compat: bool = ..., asyncio: bool = ...) -> None: ...
def compat_loop(loop: Any) -> Any: ...
def get_poll() -> Any: ...
def build_future(compat: bool = ..., asyncio: bool = ...) -> Any: ...
def ensure(
coroutine: Callable[..., Any],
args: Iterable[Any] | None = ...,
kwargs: dict | None = ...,
thread: bool | None = ...,
) -> Any: ...
def ensure_pool(
coroutine: Callable[..., Any],
args: Iterable[Any] | None = ...,
kwargs: dict | None = ...,
) -> Any: ...
35 changes: 35 additions & 0 deletions src/netius/base/container.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from typing import Any

from .common import Base
from .server import StreamServer

class Container(Base):
owner: Base | None
bases: list[Base]

def __init__(self, *args, **kwargs): ...
def start(self, owner: Base) -> None: ...
def cleanup(self) -> None: ...
def loop(self) -> None: ...
def ticks(self) -> None: ...
def connections_dict(self, full: bool = ...) -> dict[str, Any]: ...
def connection_dict(self, id: str, full: bool = ...) -> dict[str, Any] | None: ...
def on_start(self) -> None: ...
def on_stop(self) -> None: ...
def add_base(self, base: Base) -> None: ...
def remove_base(self, base: Base) -> None: ...
def start_base(self, base: Base) -> None: ...
def start_all(self) -> None: ...
def apply_all(self) -> None: ...
def apply_base(self, base: Base) -> None: ...
def call_all(self, name: str, *args, **kwargs) -> None: ...
def trigger_all(self, name: str, *args, **kwargs) -> None: ...

class ContainerServer(StreamServer):
container: Container

def __init__(self, *args, **kwargs): ...
def start(self) -> None: ...
def stop(self) -> None: ...
def cleanup(self) -> None: ...
def add_base(self, base: Base) -> None: ...
14 changes: 14 additions & 0 deletions src/netius/base/observer.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from typing import Any, Callable

class Observable:
events: dict[str, list[Callable[..., Any]]]

def __init__(self, *args, **kwargs): ...
def build(self) -> None: ...
def destroy(self) -> None: ...
def bind(
self, name: str, method: Callable[..., Any], oneshot: bool = ...
) -> None: ...
def unbind(self, name: str, method: Callable[..., Any] | None = ...) -> None: ...
def unbind_all(self) -> None: ...
def trigger(self, name: str, *args, **kwargs) -> None: ...
86 changes: 86 additions & 0 deletions src/netius/base/poll.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
from typing import Any

class Poll:
timeout: float

def __init__(self): ...
@classmethod
def name(cls) -> str: ...
@classmethod
def test(cls) -> bool: ...
def open(self, timeout: float = ...) -> None: ...
def close(self) -> None: ...
def poll(self) -> tuple[list[Any], list[Any], list[Any]]: ...
def poll_owner(self) -> dict[Any, tuple[list[Any], list[Any], list[Any]]]: ...
def is_open(self) -> bool: ...
def is_edge(self) -> bool: ...
def is_empty(self) -> bool: ...
def sub_all(self, socket: Any, owner: Any | None = ...) -> None: ...
def unsub_all(self, socket: Any) -> None: ...
def is_sub_read(self, socket: Any) -> bool: ...
def is_sub_write(self, socket: Any) -> bool: ...
def is_sub_error(self, socket: Any) -> bool: ...
def sub_read(self, socket: Any, owner: Any | None = ...) -> None: ...
def sub_write(self, socket: Any, owner: Any | None = ...) -> None: ...
def sub_error(self, socket: Any, owner: Any | None = ...) -> None: ...
def unsub_read(self, socket: Any) -> None: ...
def unsub_write(self, socket: Any) -> None: ...
def unsub_error(self, socket: Any) -> None: ...

class EpollPoll(Poll):
def __init__(self, *args, **kwargs): ...
@classmethod
def test(cls) -> bool: ...
def open(self, timeout: float = ...) -> None: ...
def close(self) -> None: ...
def poll(self) -> tuple[list[Any], list[Any], list[Any]]: ...
def is_edge(self) -> bool: ...
def sub_read(self, socket: Any, owner: Any | None = ...) -> None: ...
def sub_write(self, socket: Any, owner: Any | None = ...) -> None: ...
def sub_error(self, socket: Any, owner: Any | None = ...) -> None: ...
def unsub_read(self, socket: Any) -> None: ...
def unsub_write(self, socket: Any) -> None: ...
def unsub_error(self, socket: Any) -> None: ...

class KqueuePoll(Poll):
def __init__(self, *args, **kwargs): ...
@classmethod
def test(cls) -> bool: ...
def open(self, timeout: float = ...) -> None: ...
def close(self) -> None: ...
def poll(self) -> tuple[list[Any], list[Any], list[Any]]: ...
def is_edge(self) -> bool: ...
def sub_read(self, socket: Any, owner: Any | None = ...) -> None: ...
def sub_write(self, socket: Any, owner: Any | None = ...) -> None: ...
def sub_error(self, socket: Any, owner: Any | None = ...) -> None: ...
def unsub_read(self, socket: Any) -> None: ...
def unsub_write(self, socket: Any) -> None: ...
def unsub_error(self, socket: Any) -> None: ...

class PollPoll(Poll):
def __init__(self, *args, **kwargs): ...
@classmethod
def test(cls) -> bool: ...
def open(self, timeout: float = ...) -> None: ...
def close(self) -> None: ...
def poll(self) -> tuple[list[Any], list[Any], list[Any]]: ...
def is_edge(self) -> bool: ...
def sub_read(self, socket: Any, owner: Any | None = ...) -> None: ...
def sub_write(self, socket: Any, owner: Any | None = ...) -> None: ...
def sub_error(self, socket: Any, owner: Any | None = ...) -> None: ...
def unsub_read(self, socket: Any) -> None: ...
def unsub_write(self, socket: Any) -> None: ...
def unsub_error(self, socket: Any) -> None: ...

class SelectPoll(Poll):
def __init__(self, *args, **kwargs): ...
def open(self, timeout: float = ...) -> None: ...
def close(self) -> None: ...
def poll(self) -> tuple[list[Any], list[Any], list[Any]]: ...
def is_edge(self) -> bool: ...
def sub_read(self, socket: Any, owner: Any | None = ...) -> None: ...
def sub_write(self, socket: Any, owner: Any | None = ...) -> None: ...
def sub_error(self, socket: Any, owner: Any | None = ...) -> None: ...
def unsub_read(self, socket: Any) -> None: ...
def unsub_write(self, socket: Any) -> None: ...
def unsub_error(self, socket: Any) -> None: ...
48 changes: 48 additions & 0 deletions src/netius/base/server.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from typing import Any, Mapping

from .common import Base

class Server(Base):
socket: Any
host: str | None
port: int | str | None
type: int | None
ssl: bool
key_file: str | None
cer_file: str | None
ca_file: str | None
env: bool

def __init__(self, *args, **kwargs): ...
def welcome(self) -> None: ...
def cleanup(self) -> None: ...
def info_dict(self, full: bool = ...) -> Mapping[str, Any]: ...
def serve(
self,
host: str | None = ...,
port: int | str | None = ...,
type: int = ...,
ipv6: bool = ...,
ssl: bool = ...,
key_file: str | None = ...,
cer_file: str | None = ...,
ca_file: str | None = ...,
ca_root: bool = ...,
ssl_verify: bool = ...,
ssl_host: str | None = ...,
ssl_fingerprint: str | None = ...,
ssl_dump: bool = ...,
setuid: int | None = ...,
backlog: int = ...,
load: bool = ...,
start: bool = ...,
env: bool = ...,
) -> None: ...

class DatagramServer(Server):
def __init__(self, *args, **kwargs): ...
def reads(self, reads: list[Any], state: bool = ...) -> None: ...
def writes(self, writes: list[Any], state: bool = ...) -> None: ...
def errors(self, errors: list[Any], state: bool = ...) -> None: ...
def serve(self, type: int = ..., *args, **kwargs) -> None: ...
def on_read(self, _socket: Any) -> None: ...
31 changes: 31 additions & 0 deletions src/netius/base/service.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from typing import Any

from .observer import Observable
from .transport import Transport

Comment on lines +1 to +5
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Missing stub for transport.

You import Transport from .transport but no transport.pyi is included in this PR. Please confirm that a stub exists for this module or add it here.

🤖 Prompt for AI Agents
In src/netius/base/service.pyi around lines 1 to 5, you import Transport from
.transport but there is no transport.pyi stub file included in this PR. Verify
if transport.pyi exists in the codebase; if it does not, create a transport.pyi
stub file defining the Transport class or relevant types to ensure proper type
checking and completeness of type stubs.

class Service(Observable):
owner: Any | None
transport: Transport | None
socket: Any | None
host: str | None
port: Any | None
ssl: bool
receive_buffer_s: int | None
send_buffer_s: int | None
receive_buffer_c: int | None
send_buffer_c: int | None

def __init__(
self,
owner: Any | None = ...,
transport: Transport | None = ...,
socket: Any | None = ...,
host: str | None = ...,
port: Any | None = ...,
ssl: bool = ...,
receive_buffer_s: int | None = ...,
send_buffer_s: int | None = ...,
receive_buffer_c: int | None = ...,
send_buffer_c: int | None = ...,
): ...
def on_socket_c(self, socket_c: Any, address: Any) -> None: ...
21 changes: 21 additions & 0 deletions src/netius/base/stream.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from typing import Any

from .observer import Observable

OPEN: int
CLOSED: int
PENDING: int

class Stream(Observable):
status: int
owner: Any | None
connection: Any | None

def __init__(self, owner: Any | None = ...): ...
def reset(self) -> None: ...
def open(self) -> None: ...
def close(self) -> None: ...
def info_dict(self, full: bool = ...) -> dict[str, Any]: ...
def is_open(self) -> bool: ...
def is_closed(self) -> bool: ...
def is_pending(self) -> bool: ...
4 changes: 4 additions & 0 deletions src/netius/base/util.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def camel_to_underscore(camel: str, separator: str = ...) -> str: ...
def verify(
condition: bool, message: str | None = ..., exception: type | None = ...
) -> None: ...
Loading
Loading