Skip to content

Commit 8661499

Browse files
committed
added Python stub files generated by MyPy (+ some hand made / adjusted). helps IDEs handle typing in modules that use local imports.
1 parent a91b015 commit 8661499

43 files changed

Lines changed: 1400 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

privex_stubs/privex/__init__.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
3+
4+
from .helpers import *

privex_stubs/privex/db

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Users/chris/.local/share/virtualenvs/helpers-IG0UDhHY/lib/python3.8/site-packages/privex/db
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from .common import *
2+
from .collections import *
3+
from .decorators import *
4+
from .net import *
5+
from .exceptions import *
6+
from .plugin import *
7+
from .cache.asyncx import *
8+
from .asyncx import *
9+
from .extras import *
10+
from .converters import *
11+
from .geoip import *
12+
from .thread import *
13+
from . import plugin as plugin
14+
from .cache import CacheAdapter as CacheAdapter, CacheNotFound as CacheNotFound, CacheWrapper as CacheWrapper, MemoryCache as MemoryCache, cached as cached
15+
from .cache.RedisCache import RedisCache as RedisCache
16+
from .crypto import EncryptHelper as EncryptHelper, Format as Format, KeyManager as KeyManager, auto_b64decode as auto_b64decode, is_base64 as is_base64
17+
from .setuppy.bump import bump_version as bump_version, get_current_ver as get_current_ver
18+
from .setuppy.commands import BumpCommand as BumpCommand, ExtrasCommand as ExtrasCommand
19+
from .setuppy.common import extras_require as extras_require, reqs as reqs
20+
from typing import Any
21+
22+
log: Any
23+
name: str
24+
VERSION: str
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import queue
2+
import threading
3+
from privex.helpers.types import STRBYTES, T
4+
from typing import Any, Awaitable, Callable, Coroutine, List, Optional, Tuple, Type, Union
5+
6+
def coro_thread_func(func: callable, *t_args: Any, _output_queue: Optional[Union[queue.Queue, str]]=..., **t_kwargs: Any) -> Any: ...
7+
def run_coro_thread_base(func: callable, *args: Any, _daemon_thread: Any=..., **kwargs: Any) -> threading.Thread: ...
8+
def run_coro_thread(func: callable, *args: Any, **kwargs: Any) -> Any: ...
9+
async def run_coro_thread_async(func: callable, *args: Any, _queue_timeout: Any=..., _queue_sleep: Any=..., **kwargs: Any) -> Any: ...
10+
def run_sync(func: Any, *args: Any, **kwargs: Any): ...
11+
def loop_run(coro: Union[Coroutine, Type[Coroutine], Callable], *args: Any, _loop: Any=..., **kwargs: Any) -> Any: ...
12+
def async_sync(f: Any): ...
13+
async def call_sys_async(proc: Any, *args: Any, write: STRBYTES=..., **kwargs: Any) -> Tuple[bytes, bytes]: ...
14+
async def await_if_needed(func: Union[callable, Coroutine, Awaitable, Any], *args: Any, **kwargs: Any) -> Any: ...
15+
def get_async_type(obj: Any) -> str: ...
16+
17+
AWAITABLE_BLACKLIST_FUNCS: List[str]
18+
AWAITABLE_BLACKLIST_MODS: List[str]
19+
AWAITABLE_BLACKLIST: List[str]
20+
21+
def is_async_context() -> bool: ...
22+
23+
class AwaitableMixin:
24+
def __getattribute__(self, item: Any): ...
25+
26+
def awaitable_class(cls: Type[T]) -> Type[T]: ...
27+
def awaitable(func: Callable) -> Callable: ...
28+
29+
class aobject:
30+
__new__: Any = ...
31+
__init__: Any = ...
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import abc
2+
from abc import ABC, abstractmethod
3+
from privex.helpers.asyncx import await_if_needed as await_if_needed
4+
from privex.helpers.common import empty_if as empty_if
5+
from privex.helpers.exceptions import CacheNotFound as CacheNotFound
6+
from privex.helpers.settings import DEFAULT_CACHE_TIMEOUT as DEFAULT_CACHE_TIMEOUT
7+
from privex.helpers.types import VAL_FUNC_CORO as VAL_FUNC_CORO
8+
from typing import Any, Optional, Union
9+
10+
class CacheAdapter(ABC, metaclass=abc.ABCMeta):
11+
adapter_enter_reconnect: bool = ...
12+
adapter_exit_close: bool = ...
13+
ins_enter_reconnect: bool
14+
ins_exit_close: bool
15+
def __init__(self, *args: Any, enter_reconnect: Optional[bool]=..., exit_close: Optional[bool]=..., **kwargs: Any) -> None: ...
16+
@abstractmethod
17+
def get(self, key: str, default: Any=..., fail: bool=...) -> Any: ...
18+
@abstractmethod
19+
def set(self, key: str, value: Any, timeout: Optional[int]=...) -> Any: ...
20+
@abstractmethod
21+
def remove(self, *key: str) -> bool: ...
22+
@abstractmethod
23+
def update_timeout(self, key: str, timeout: int=...) -> Any: ...
24+
def get_or_set(self, key: str, value: Union[Any, callable], timeout: int=...) -> Any: ...
25+
async def get_or_set_async(self, key: str, value: VAL_FUNC_CORO, timeout: int=...) -> Any: ...
26+
def close(self, *args: Any, **kwargs: Any) -> Any: ...
27+
def connect(self, *args: Any, **kwargs: Any) -> Any: ...
28+
def reconnect(self, *args: Any, **kwargs: Any) -> Any: ...
29+
def __getitem__(self, item: Any): ...
30+
def __setitem__(self, key: Any, value: Any): ...
31+
async def __aenter__(self): ...
32+
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None: ...
33+
def __enter__(self): ...
34+
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None: ...
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from privex.helpers.cache.CacheAdapter import CacheAdapter as CacheAdapter
2+
from privex.helpers.exceptions import CacheNotFound as CacheNotFound
3+
from privex.helpers.settings import DEFAULT_CACHE_TIMEOUT as DEFAULT_CACHE_TIMEOUT
4+
from typing import Any, Optional, Union
5+
6+
log: Any
7+
8+
class MemoryCache(CacheAdapter):
9+
def get(self, key: str, default: Any=..., fail: bool=...) -> Any: ...
10+
def set(self, key: str, value: Any, timeout: Optional[int]=...) -> Any: ...
11+
def get_or_set(self, key: str, value: Union[Any, callable], timeout: int=...) -> Any: ...
12+
def remove(self, *key: str) -> bool: ...
13+
def update_timeout(self, key: str, timeout: int=...) -> Any: ...
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from privex.helpers import plugin as plugin
2+
from privex.helpers.cache.CacheAdapter import CacheAdapter as CacheAdapter
3+
from privex.helpers.common import empty as empty
4+
from privex.helpers.exceptions import CacheNotFound as CacheNotFound
5+
from privex.helpers.plugin import close_redis as close_redis, get_redis as get_redis
6+
from privex.helpers.settings import DEFAULT_CACHE_TIMEOUT as DEFAULT_CACHE_TIMEOUT
7+
from redis import Redis
8+
from typing import Any, Optional
9+
10+
log: Any
11+
12+
class RedisCache(CacheAdapter):
13+
pickle_default: bool = ...
14+
use_pickle: bool
15+
def __init__(self, use_pickle: bool=..., redis_instance: Redis=..., *args: Any, **kwargs: Any) -> None: ...
16+
@property
17+
def redis(self) -> Redis: ...
18+
def get(self, key: str, default: Any=..., fail: bool=...) -> Any: ...
19+
def set(self, key: str, value: Any, timeout: Optional[int]=...) -> Any: ...
20+
def remove(self, *key: str) -> bool: ...
21+
def update_timeout(self, key: str, timeout: int=...) -> Any: ...
22+
def connect(self, *args: Any, **kwargs: Any) -> Redis: ...
23+
def close(self): ...
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from privex.helpers import settings as settings
2+
from privex.helpers.cache.CacheAdapter import CacheAdapter as CacheAdapter
3+
from privex.helpers.common import empty as empty, empty_if as empty_if, is_true as is_true
4+
from privex.helpers.exceptions import CacheNotFound as CacheNotFound
5+
from typing import Any, Optional
6+
7+
from privex.helpers.cache.post_deps import SqliteCacheManager, SqliteCacheResult
8+
9+
log: Any
10+
11+
12+
def _cache_result_expired(res: SqliteCacheResult, _auto_purge=True) -> bool: ...
13+
14+
15+
class SqliteCache(CacheAdapter):
16+
pickle_default: bool = ...
17+
use_pickle: bool
18+
last_purged_expired: Optional[int] = ...
19+
db_file: Any = ...
20+
db_folder: Any = ...
21+
connection_kwargs: Any = ...
22+
memory_persist: Any = ...
23+
purge_every: Any = ...
24+
_wrapper: Optional[SqliteCacheManager] = ...
25+
26+
def __init__(self, db_file: str=..., memory_persist: Any=..., use_pickle: bool=..., connection_kwargs: dict=..., *args: Any, **kwargs: Any) -> None: ...
27+
28+
@property
29+
def purge_due(self) -> bool: ...
30+
31+
@property
32+
def wrapper(self) -> SqliteCacheManager: ...
33+
34+
def purge_expired(self, force: Any=...) -> Optional[int]: ...
35+
def get(self, key: str, default: Any=..., fail: bool=..., _auto_purge: Any=...) -> Any: ...
36+
def set(self, key: str, value: Any, timeout: Optional[int]=..., _auto_purge: Any=...) -> Any: ...
37+
def remove(self, *key: str) -> bool: ...
38+
def update_timeout(self, key: str, timeout: int=...) -> Any: ...
39+
def connect(self, db: Any=..., *args: Any, connection_kwargs: Any=..., memory_persist: Any=..., **kwargs: Any) -> SqliteCacheManager: ...
40+
def close(self) -> None: ...
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
from .asyncx import *
2+
from privex.helpers import plugin as plugin
3+
from privex.helpers.asyncx import await_if_needed as await_if_needed, awaitable as awaitable, loop_run as loop_run
4+
from .CacheAdapter import CacheAdapter as CacheAdapter
5+
from .MemoryCache import MemoryCache as MemoryCache
6+
from .RedisCache import RedisCache as RedisCache
7+
from .SqliteCache import SqliteCache as SqliteCache
8+
from privex.helpers.common import LayeredContext as LayeredContext, empty_if as empty_if
9+
from privex.helpers.exceptions import CacheNotFound as CacheNotFound, NotConfigured as NotConfigured
10+
from privex.helpers.settings import DEFAULT_CACHE_TIMEOUT as DEFAULT_CACHE_TIMEOUT
11+
from typing import Any, Optional, Type, Union
12+
13+
log: Any
14+
CLSCacheAdapter = Union[Type[CacheAdapter], Type[AsyncCacheAdapter]]
15+
INSCacheAdapter = Union[CacheAdapter, AsyncCacheAdapter]
16+
ANYCacheAdapter = Union[CLSCacheAdapter, INSCacheAdapter]
17+
18+
class CacheWrapper:
19+
cache_instance: Optional[INSCacheAdapter] = ...
20+
default_adapter: Type[CLSCacheAdapter] = ...
21+
instance_args: Any = ...
22+
instance_kwargs: Any = ...
23+
max_context_layers: int = ...
24+
@classmethod
25+
def get_context_tracker(cls: Any, reset: bool=...) -> LayeredContext: ...
26+
@classmethod
27+
def reset_context_tracker(cls: Any) -> LayeredContext: ...
28+
@classmethod
29+
def get_adapter(cls: Any, default: CLSCacheAdapter=..., *args: Any, **kwargs: Any) -> INSCacheAdapter: ...
30+
@classmethod
31+
def set_adapter(cls: Any, adapter: ANYCacheAdapter, *args: Any, **kwargs: Any) -> INSCacheAdapter: ...
32+
@classmethod
33+
def reset_adapter(cls: Any, default: CLSCacheAdapter=..., *args: Any, **kwargs: Any) -> INSCacheAdapter: ...
34+
def __getattr__(self, item: Any): ...
35+
def __getitem__(self, item: Any): ...
36+
def __setitem__(self, key: Any, value: Any): ...
37+
async def __aenter__(self): ...
38+
async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any): ...
39+
def __enter__(self): ...
40+
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any): ...
41+
42+
cached: Union[CacheAdapter, CacheWrapper]
43+
44+
class AsyncCacheWrapper(CacheWrapper):
45+
cache_instance: AsyncCacheAdapter = ...
46+
instance_args: Any = ...
47+
instance_kwargs: Any = ...
48+
default_adapter: Type[AsyncCacheAdapter] = ...
49+
max_context_layers: int = ...
50+
@classmethod
51+
def get_adapter(cls: Any, default: Type[AsyncCacheAdapter]=..., *args: Any, **kwargs: Any) -> AsyncCacheAdapter: ...
52+
@classmethod
53+
def set_adapter(cls: Any, adapter: AsyncCacheAdapter, *args: Any, **kwargs: Any) -> AsyncCacheAdapter: ...
54+
@classmethod
55+
def reset_adapter(cls: Any, default: Type[AsyncCacheAdapter]=..., *args: Any, **kwargs: Any) -> AsyncCacheAdapter: ...
56+
def __getattr__(self, item: Any): ...
57+
def __getitem__(self, item: Any): ...
58+
def __setitem__(self, key: Any, value: Any): ...
59+
def __enter__(self): ...
60+
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any): ...
61+
62+
async_cached: Union[AsyncCacheAdapter, AsyncCacheWrapper]
63+
64+
def async_adapter_set(adapter: AsyncCacheAdapter) -> AsyncCacheAdapter: ...
65+
def async_adapter_get(default: Type[AsyncCacheAdapter]=...) -> AsyncCacheAdapter: ...
66+
def adapter_set(adapter: CacheAdapter) -> Any: ...
67+
def adapter_get(default: Type[CacheAdapter]=...) -> CacheAdapter: ...
68+
def get(key: str, default: Any=..., fail: bool=...) -> Any: ...
69+
def set(key: str, value: Any, timeout: Optional[int]=...) -> Any: ...
70+
def get_or_set(key: str, value: Union[Any, callable], timeout: int=...) -> Any: ...
71+
def remove(*key: str) -> bool: ...
72+
def update_timeout(key: str, timeout: int=...) -> Any: ...
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import aiomcache
2+
from privex.helpers.cache.asyncx.base import AsyncCacheAdapter as AsyncCacheAdapter
3+
from privex.helpers.common import byteify as byteify, empty as empty
4+
from privex.helpers.exceptions import CacheNotFound as CacheNotFound
5+
from privex.helpers.plugin import close_memcached_async as close_memcached_async, get_memcached_async as get_memcached_async
6+
from privex.helpers.settings import DEFAULT_CACHE_TIMEOUT as DEFAULT_CACHE_TIMEOUT
7+
from typing import Any, Optional, Union
8+
9+
log: Any
10+
11+
class AsyncMemcachedCache(AsyncCacheAdapter):
12+
pickle_default: bool = ...
13+
use_pickle: bool
14+
adapter_enter_reconnect: bool = ...
15+
adapter_exit_close: bool = ...
16+
def __init__(self, use_pickle: bool=..., mcache_instance: aiomcache.Client=..., *args: Any, **kwargs: Any) -> None: ...
17+
async def mcache(self) -> aiomcache.Client: ...
18+
async def get(self, key: Union[bytes, str], default: Any=..., fail: bool=...) -> Any: ...
19+
async def set(self, key: Union[bytes, str], value: Any, timeout: Optional[int]=...) -> Any: ...
20+
async def remove(self, *key: Union[bytes, str]) -> bool: ...
21+
async def update_timeout(self, key: str, timeout: int=...) -> Any: ...
22+
async def connect(self, *args: Any, new_connection: Any=..., **kwargs: Any) -> aiomcache.Client: ...
23+
async def close(self): ...

0 commit comments

Comments
 (0)