Skip to content

Commit

Permalink
Merge branch 'typing' of github.com:hivesolutions/netius into typing
Browse files Browse the repository at this point in the history
  • Loading branch information
hugo-gomes committed Dec 21, 2023
2 parents 26acf62 + 58012d5 commit 0c20933
Show file tree
Hide file tree
Showing 125 changed files with 4,629 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/typings/netius/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from . import adapters as adapters, auth as auth, middleware as middleware, pool as pool
from .adapters import fs as fs, mongo as mongo, null as null
from .auth import address as address, allow as allow, base as base, deny as deny, dummy as dummy, memory as memory, passwd as passwd, simple as simple
from .base import agent as agent, async_neo as async_neo, async_old as async_old, asynchronous as asynchronous, client as client, common as common, compat as compat, config as config, conn as conn, container as container, errors as errors, legacy as legacy, log as log, observer as observer, poll as poll, protocol as protocol, request as request, server as server, stream as stream, tls as tls, transport as transport, util as util
from netius.adapters.base import BaseAdapter as BaseAdapter
from netius.adapters.fs import FsAdapter as FsAdapter
from netius.adapters.memory import MemoryAdapter as MemoryAdapter
from netius.adapters.mongo import MongoAdapter as MongoAdapter
from netius.adapters.null import NullAdapter as NullAdapter
from netius.auth.address import AddressAuth as AddressAuth
from netius.auth.allow import AllowAuth as AllowAuth
from netius.auth.base import Auth as Auth
from netius.auth.deny import DenyAuth as DenyAuth
from netius.auth.dummy import DummyAuth as DummyAuth
from netius.auth.memory import MemoryAuth as MemoryAuth
from netius.auth.passwd import PasswdAuth as PasswdAuth
from netius.auth.simple import SimpleAuth as SimpleAuth
from netius.base.agent import Agent as Agent, ClientAgent as ClientAgent, ServerAgent as ServerAgent
from netius.base.async_neo import Future as Future, coroutine as coroutine, coroutine_return as coroutine_return, ensure_generator as ensure_generator, get_asyncio as get_asyncio, is_coroutine as is_coroutine, is_coroutine_native as is_coroutine_native, is_coroutine_object as is_coroutine_object, is_future as is_future, sleep as sleep, wait as wait
from netius.base.async_old import Executor as Executor, Handle as Handle, Task as Task, ThreadPoolExecutor as ThreadPoolExecutor, async_test as async_test, async_test_all as async_test_all, is_asynclib as is_asynclib, is_await as is_await, is_neo as is_neo, notify as notify, wakeup as wakeup
from netius.base.client import Client as Client, DatagramClient as DatagramClient, StreamClient as StreamClient
from netius.base.common import Base as Base, BaseThread as BaseThread, build_future as build_future, compat_loop as compat_loop, ensure as ensure, ensure_asyncio as ensure_asyncio, ensure_loop as ensure_loop, ensure_main as ensure_main, ensure_pool as ensure_pool, get_event_loop as get_event_loop, get_loop as get_loop, get_main as get_main, get_poll as get_poll, new_loop as new_loop, new_loop_asyncio as new_loop_asyncio, new_loop_main as new_loop_main, stop_loop as stop_loop
from netius.base.compat import CompatLoop as CompatLoop, build_datagram as build_datagram, connect_stream as connect_stream, is_asyncio as is_asyncio, is_compat as is_compat
from netius.base.config import conf as conf, conf_ctx as conf_ctx, conf_d as conf_d, conf_prefix as conf_prefix, conf_r as conf_r, conf_s as conf_s, conf_suffix as conf_suffix
from netius.base.conn import Connection as Connection
from netius.base.container import Container as Container, ContainerServer as ContainerServer
from netius.base.errors import AssertionError as AssertionError, DataError as DataError, GeneratorError as GeneratorError, NetiusError as NetiusError, NotImplemented as NotImplemented, ParserError as ParserError, PauseError as PauseError, RuntimeError as RuntimeError, SecurityError as SecurityError, StopError as StopError, WakeupError as WakeupError
from netius.base.log import rotating_handler as rotating_handler, smtp_handler as smtp_handler
from netius.base.observer import Observable as Observable
from netius.base.poll import EpollPoll as EpollPoll, KqueuePoll as KqueuePoll, Poll as Poll, PollPoll as PollPoll, SelectPoll as SelectPoll
from netius.base.protocol import DatagramProtocol as DatagramProtocol, Protocol as Protocol, StreamProtocol as StreamProtocol
from netius.base.request import Request as Request, Response as Response
from netius.base.server import DatagramServer as DatagramServer, Server as Server, StreamServer as StreamServer
from netius.base.stream import Stream as Stream
from netius.base.tls import dnsname_match as dnsname_match, dump_certificate as dump_certificate, fingerprint as fingerprint, match_fingerprint as match_fingerprint, match_hostname as match_hostname
from netius.base.transport import Transport as Transport, TransportDatagram as TransportDatagram, TransportStream as TransportStream
from netius.base.util import camel_to_underscore as camel_to_underscore, verify as verify

__version__: str
__revision__: str
__date__: str
NAME: str
VERSION: str
IDENTIFIER_SHORT: str
IDENTIFIER_LONG: str
IDENTIFIER: str
TCP_TYPE: int
UDP_TYPE: int
SSL_KEY_PATH: str
SSL_CER_PATH: str
SSL_CA_PATH: None
SSL_DH_PATH: str
OPEN: int
CLOSED: int
PENDING: int
CHUNK_SIZE: int
SILENT: int
6 changes: 6 additions & 0 deletions src/typings/netius/adapters/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from . import base as base, fs as fs, memory as memory, mongo as mongo, null as null
from netius.adapters.base import BaseAdapter as BaseAdapter
from netius.adapters.fs import FsAdapter as FsAdapter
from netius.adapters.memory import MemoryAdapter as MemoryAdapter
from netius.adapters.mongo import MongoAdapter as MongoAdapter
from netius.adapters.null import NullAdapter as NullAdapter
17 changes: 17 additions & 0 deletions src/typings/netius/adapters/base.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import netius as netius
from typing import Any

class BaseAdapter:
def set(self, value: Any, owner: str = ...) -> None: ...
def get(self, key: str) -> str | netius.legacy.StringIO: ...
def get_file(self, key: str, mode: str = ...) -> netius.legacy.StringIO: ...
def delete(self, key: str, owner: str = ...): ...
def append(self, key:str , value: Any) -> None: ...
def truncate(self, key:str , count: int) -> None: ...
def size(self, key:str ) -> int: ...
def sizes(self, owner: str | None = ...) -> list[int]: ...
def total(self, owner: str | None = ...) -> int: ...
def reserve(self, owner: str = ...) -> None: ...
def count(self, owner: str | None = ...) -> int: ...
def list(self, owner: str | None = ...) -> tuple[()]: ...
def generate(self) -> str: ...
17 changes: 17 additions & 0 deletions src/typings/netius/adapters/fs.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import netius as netius
import netius.adapters.base
import netius.adapters.base as base
from typing import StrOrBytesPath
from typing import Any

class FsAdapter(netius.adapters.base.BaseAdapter):
def __init__(self, base_path: str | None = ...) -> None: ...
def set(self, value: Any, owner: str = ...) -> str: ...
def get_file(self, key: str, mode: str = ...) -> netius.legacy.StringIO: ...
def delete(self, key: str, owner: str = ...) -> None: ...
def size(self, key:str ) -> int: ...
def count(self, owner: str | None = ...) -> int: ...
def list(self, owner: str | None = ...) -> list[str]: ...
def _path(self, owner: str | None = ...) -> str: ...
def _ensure(self, owner: str) -> str: ...
def _symlink(self, source: StrOrBytesPath, target: StrOrBytesPath) -> None: ...
17 changes: 17 additions & 0 deletions src/typings/netius/adapters/memory.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import netius as netius
import netius.adapters.base
import netius.adapters.base as base
from typing import Any

class MemoryAdapter(netius.adapters.base.BaseAdapter):
def __init__(self) -> None: ...
def set(self, value, owner: str = ...) -> str: ...
def get_file(self, key: str, mode: str = ...) -> netius.legacy.StringIO: ...
def delete(self, key: str, owner: str = ...) -> None: ...
def append(self, key: str, value: Any) -> None: ...
def truncate(self, key: str, count: int) -> None: ...
def size(self, key: str) -> int: ...
def count(self, owner: str | None = ...) -> int: ...
def list(self, owner: str | None = ...) -> tuple[()]: ...
def _ensure(self, owner: str) -> dict: ...
def _build_close(self, file: netius.legacy.StringIO, key: str) -> function: ...
6 changes: 6 additions & 0 deletions src/typings/netius/adapters/mongo.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import netius.adapters.base
import netius.adapters.base as base

class MongoAdapter(netius.adapters.base.BaseAdapter):
def set(self, value, owner: str = ...): ...
def get(self, key): ...
4 changes: 4 additions & 0 deletions src/typings/netius/adapters/null.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import netius.adapters.base
import netius.adapters.base as base

class NullAdapter(netius.adapters.base.BaseAdapter): ...
13 changes: 13 additions & 0 deletions src/typings/netius/auth/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from . import address as address, allow as allow, base as base, deny as deny, dummy as dummy, memory as memory, passwd as passwd, simple as simple
from netius.auth.address import AddressAuth as AddressAuth
from netius.auth.allow import AllowAuth as AllowAuth
from netius.auth.base import Auth as Auth
from netius.auth.deny import DenyAuth as DenyAuth
from netius.auth.dummy import DummyAuth as DummyAuth
from netius.auth.memory import MemoryAuth as MemoryAuth
from netius.auth.passwd import PasswdAuth as PasswdAuth
from netius.auth.simple import SimpleAuth as SimpleAuth

__version__: str
__revision__: str
__date__: str
11 changes: 11 additions & 0 deletions src/typings/netius/auth/address.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import netius.auth.base
import netius.auth.base as base
from typing import Literal

class AddressAuth(netius.auth.base.Auth):
def __init__(self, allowed: list = ..., *args, **kwargs) -> None: ...
@classmethod
def auth(cls, allowed: list = ..., *args, **kwargs) -> bool: ...
@classmethod
def is_simple(cls) -> Literal[True]: ...
def auth_i(self, *args, **kwargs): ...
9 changes: 9 additions & 0 deletions src/typings/netius/auth/allow.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import netius.auth.base
import netius.auth.base as base
from typing import Literal

class AllowAuth(netius.auth.base.Auth):
@classmethod
def auth(cls, *args, **kwargs) -> Literal[True]: ...
@classmethod
def is_simple(cls) -> Literal[True]: ...
24 changes: 24 additions & 0 deletions src/typings/netius/auth/base.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import netius as netius
from typing import NoReturn, Any, Unbound, Literal, PathLike

class Auth:
def __init__(self, *args, **kwargs) -> None: ...
@classmethod
def auth(cls, *args, **kwargs) -> NoReturn: ...
@classmethod
def meta(cls, *args, **kwargs) -> dict: ...
@classmethod
def auth_assert(cls, *args, **kwargs) -> None: ...
@classmethod
def verify(cls, encoded: str, decoded: str) -> bool: ...
@classmethod
def generate(cls, password: str, type: str = ..., salt: str = ...) -> str: ...
@classmethod
def unpack(cls, password) -> tuple[Any | Literal["plain"], bytes | Any | str | None, Any | None, Unbound | Any | None]: ...
@classmethod
def get_file(cls, path: PathLike[str], cache: bool = ..., encoding: str | None = ...) -> (Any | str | bytes): ...
@classmethod
def is_simple(cls) -> Literal[False]: ...
def auth_i(self, *args, **kwargs) -> NoReturn: ...
def auth_assert_i(self, *args, **kwargs) -> None: ...
def is_simple_i(self) -> Literal[False]: ...
10 changes: 10 additions & 0 deletions src/typings/netius/auth/deny.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import netius.auth.base
import netius.auth.base as base

from typing import Literal

class DenyAuth(netius.auth.base.Auth):
@classmethod
def auth(cls, *args, **kwargs) -> Literal[False]: ...
@classmethod
def is_simple(cls) -> Literal[True]: ...
11 changes: 11 additions & 0 deletions src/typings/netius/auth/dummy.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import netius.auth.base
import netius.auth.base as base
from typing import Literal

class DummyAuth(netius.auth.base.Auth):
def __init__(self, value: bool = ..., *args, **kwargs) -> None: ...
@classmethod
def auth(cls, value: bool = ..., *args, **kwargs): ...
@classmethod
def is_simple(cls) -> Literal[True]: ...
def auth_i(self, *args, **kwargs) -> bool: ...
19 changes: 19 additions & 0 deletions src/typings/netius/auth/memory.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import netius as netius
import netius.auth.base
import netius.auth.base as base

from typing import Dict

class MemoryAuth(netius.auth.base.Auth):
def __init__(self, registry: Dict | None = ..., *args, **kwargs) -> None: ...
@classmethod
def auth(
cls, username: str, password: str, registry: dict | None = ..., *args, **kwargs
): ...
@classmethod
def meta(cls, username: str, registry: Dict | None = ..., *args, **kwargs) -> Dict: ...
@classmethod
def get_registry(cls): ...
@classmethod
def load_registry(cls): ...
def auth_i(self, username: str, password: str, *args, **kwargs) -> bool: ...
12 changes: 12 additions & 0 deletions src/typings/netius/auth/passwd.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import netius.auth.base
import netius.auth.base as base

from typing import PathLike, Any, Dict

class PasswdAuth(netius.auth.base.Auth):
def __init__(self, path: PathLike[str] | None = ..., *args, **kwargs) -> None: ...
@classmethod
def auth(cls, username: str, password: str, path: str = ..., *args, **kwargs) -> bool: ...
@classmethod
def get_passwd(cls, path: PathLike[str], cache: bool = ...) -> (Any | Dict): ...
def auth_i(self, username: str, password: str, *args, **kwargs) -> bool: ...
9 changes: 9 additions & 0 deletions src/typings/netius/auth/simple.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import netius.auth.base
import netius.auth.base as base
from typing import Tuple

class SimpleAuth(netius.auth.base.Auth):
def __init__(self, username: str | None = ..., password: str | None = ..., *args, **kwargs) -> None: ...
@classmethod
def auth(cls, username: str, password: str, target: Tuple[str:str] | None = ..., *args, **kwargs) -> bool: ...
def auth_i(self, username:str , password: str, *args, **kwargs) -> bool: ...
41 changes: 41 additions & 0 deletions src/typings/netius/base/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from . import agent as agent, async_neo as async_neo, async_old as async_old, asynchronous as asynchronous, client as client, common as common, compat as compat, config as config, conn as conn, container as container, errors as errors, legacy as legacy, log as log, observer as observer, poll as poll, protocol as protocol, request as request, server as server, stream as stream, tls as tls, transport as transport, util as util
from netius.base.agent import Agent as Agent, ClientAgent as ClientAgent, ServerAgent as ServerAgent
from netius.base.async_neo import Future as Future, coroutine as coroutine, coroutine_return as coroutine_return, ensure_generator as ensure_generator, get_asyncio as get_asyncio, is_coroutine as is_coroutine, is_coroutine_native as is_coroutine_native, is_coroutine_object as is_coroutine_object, is_future as is_future, sleep as sleep, wait as wait
from netius.base.async_old import Executor as Executor, Handle as Handle, Task as Task, ThreadPoolExecutor as ThreadPoolExecutor, async_test as async_test, async_test_all as async_test_all, is_asynclib as is_asynclib, is_await as is_await, is_neo as is_neo, notify as notify, wakeup as wakeup
from netius.base.client import Client as Client, DatagramClient as DatagramClient, StreamClient as StreamClient
from netius.base.common import Base as Base, BaseThread as BaseThread, build_future as build_future, compat_loop as compat_loop, ensure as ensure, ensure_asyncio as ensure_asyncio, ensure_loop as ensure_loop, ensure_main as ensure_main, ensure_pool as ensure_pool, get_event_loop as get_event_loop, get_loop as get_loop, get_main as get_main, get_poll as get_poll, new_loop as new_loop, new_loop_asyncio as new_loop_asyncio, new_loop_main as new_loop_main, stop_loop as stop_loop
from netius.base.compat import CompatLoop as CompatLoop, build_datagram as build_datagram, connect_stream as connect_stream, is_asyncio as is_asyncio, is_compat as is_compat
from netius.base.config import conf as conf, conf_ctx as conf_ctx, conf_d as conf_d, conf_prefix as conf_prefix, conf_r as conf_r, conf_s as conf_s, conf_suffix as conf_suffix
from netius.base.conn import Connection as Connection
from netius.base.container import Container as Container, ContainerServer as ContainerServer
from netius.base.errors import AssertionError as AssertionError, DataError as DataError, GeneratorError as GeneratorError, NetiusError as NetiusError, NotImplemented as NotImplemented, ParserError as ParserError, PauseError as PauseError, RuntimeError as RuntimeError, SecurityError as SecurityError, StopError as StopError, WakeupError as WakeupError
from netius.base.log import rotating_handler as rotating_handler, smtp_handler as smtp_handler
from netius.base.observer import Observable as Observable
from netius.base.poll import EpollPoll as EpollPoll, KqueuePoll as KqueuePoll, Poll as Poll, PollPoll as PollPoll, SelectPoll as SelectPoll
from netius.base.protocol import DatagramProtocol as DatagramProtocol, Protocol as Protocol, StreamProtocol as StreamProtocol
from netius.base.request import Request as Request, Response as Response
from netius.base.server import DatagramServer as DatagramServer, Server as Server, StreamServer as StreamServer
from netius.base.stream import Stream as Stream
from netius.base.tls import dnsname_match as dnsname_match, dump_certificate as dump_certificate, fingerprint as fingerprint, match_fingerprint as match_fingerprint, match_hostname as match_hostname
from netius.base.transport import Transport as Transport, TransportDatagram as TransportDatagram, TransportStream as TransportStream
from netius.base.util import camel_to_underscore as camel_to_underscore, verify as verify

__version__: str
__revision__: str
__date__: str
NAME: str
VERSION: str
IDENTIFIER_SHORT: str
IDENTIFIER_LONG: str
IDENTIFIER: str
TCP_TYPE: int
UDP_TYPE: int
SSL_KEY_PATH: str
SSL_CER_PATH: str
SSL_CA_PATH: None
SSL_DH_PATH: str
OPEN: int
CLOSED: int
PENDING: int
CHUNK_SIZE: int
SILENT: int
20 changes: 20 additions & 0 deletions src/typings/netius/base/agent.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import netius.base.legacy as legacy
import netius.base.observer
import netius.base.observer as observer
from typing import ClassVar, Any, Self


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

class ClientAgent(Agent):
_clients: ClassVar[dict] = ...
@classmethod
def cleanup_s(cls) -> None: ...
@classmethod
def get_client_s(cls, *args, **kwargs)-> Self@ClientAgent: ...

class ServerAgent(Agent): ...
45 changes: 45 additions & 0 deletions src/typings/netius/base/async_neo.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import netius.base.async_old
import netius.base.async_old as async_old
import netius.base.errors as errors
import netius.base.legacy as legacy
from typing import ClassVar, Any, Generator, Tuple, Union, Callable, Optional, Type, ModuleType

class Future(netius.base.async_old.Future):
def __iter__(self) -> Future: ...
def __await__(self) -> Generator[None, None, Any]: ...

class Future:
def __iter__(self) -> Future: ...
def __await__(self) -> Generator[None, None, Any]: ...

class AwaitWrapper:
_is_generator: ClassVar[bool] = ...
def __init__(self, generator: Generator, generate: bool = ...) -> None: ...
def __await__(self)-> (Generator[Any, Any, Any | None] | Generator[None, Any, Generator[Any, Any, None] | Any]): ...
def __iter__(self) -> AwaitWrapper: ...
def __next__(self) -> Any: ...
def next(self) -> Any: ...
def generate(self, value: Any) -> Generator[Any, Any, None]: ...
def _await_generator(self) -> Generator[Any, Any, Any | None]: ...
def _await_basic(self) -> Generator[None, Any, Generator[Any, Any, None] | Any]: ...

class CoroutineWrapper:
def __init__(self, coroutine: Generator) -> None: ...
def __iter__(self) -> CoroutineWrapper: ...
def __next__(self) -> Any: ...
def next(self) -> Any: ...
def restore(self, value: Any) -> None: ...

def coroutine(function: Callable) -> Callable: ...
def ensure_generator(value: Any) -> Tuple[bool, Union[Generator, CoroutineWrapper, Any]]: ...
def get_asyncio() -> Optional[Type[ModuleType]]: ...
def is_coroutine(callable: Callable) -> bool: ...
def is_coroutine_object(generator: Any) -> bool: ...
def is_coroutine_native(generator: Any) -> bool: ...
def is_future(future: Any) -> bool: ...
def _sleep(timeout: float, compat: bool = ...) -> Generator: ...
def _wait(event: Any, timeout: Optional[float] = ..., future: Any = ...) -> AwaitWrapper: ...
def sleep(*args, **kwargs) -> AwaitWrapper: ...
def wait(*args, **kwargs) -> AwaitWrapper: ...
def coroutine_return(coroutine: CoroutineWrapper) -> AwaitWrapper: ...
def _coroutine_return(coroutine: CoroutineWrapper) -> Generator[Any, None, Any]: ...
Loading

0 comments on commit 0c20933

Please sign in to comment.