Skip to content
Merged
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
60 changes: 45 additions & 15 deletions stubs/boltons/boltons/cacheutils.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import weakref
from _typeshed import Incomplete, Self, SupportsItems, SupportsKeysAndGetItem
from _typeshed import Incomplete, SupportsItems, SupportsKeysAndGetItem
from collections.abc import Callable, Generator, Hashable, Iterable, Iterator, Mapping
from typing import Any, Generic, TypeVar, overload
from typing_extensions import Self

_KT = TypeVar("_KT")
_VT = TypeVar("_VT")
Expand All @@ -18,8 +19,10 @@ class LRI(dict[_KT, _VT]):
miss_count: int
soft_miss_count: int
max_size: int
on_miss: Callable[[_KT], _VT]
def __init__(self, max_size: int = 128, values: Incomplete | None = None, on_miss: Incomplete | None = None) -> None: ...
on_miss: Callable[[_KT], _VT] | None
def __init__(
self, max_size: int = 128, values: Incomplete | None = None, on_miss: Callable[[_KT], _VT] | None = None
) -> None: ...
def __setitem__(self, key: _KT, value: _VT) -> None: ...
def __getitem__(self, key: _KT) -> _VT: ...
@overload
Expand All @@ -33,9 +36,9 @@ class LRI(dict[_KT, _VT]):
def pop(self, key: _KT, default: _T) -> _T | _VT: ...
def popitem(self) -> tuple[_KT, _VT]: ...
def clear(self) -> None: ...
def copy(self: Self) -> Self: ...
def copy(self) -> Self: ...
@overload
def setdefault(self, key: _KT, default: None = None) -> _VT: ...
def setdefault(self, key: _KT, default: None = None) -> _VT | None: ...
@overload
def setdefault(self, key: _KT, default: _VT) -> _VT: ...
def update(self, E: SupportsKeysAndGetItem[_KT, _VT] | Iterable[tuple[_KT, _VT]], **F: _VT) -> None: ... # type: ignore[override]
Expand All @@ -57,7 +60,14 @@ class CachedFunction:
scoped: Incomplete
typed: Incomplete
key_func: Incomplete
def __init__(self, func, cache, scoped: bool = True, typed: bool = False, key: Incomplete | None = None): ...
def __init__(
self,
func,
cache: Mapping[Any, Any] | Callable[..., Incomplete],
scoped: bool = True,
typed: bool = False,
key: Callable[..., Incomplete] | None = None,
): ...
def __call__(self, *args, **kwargs): ...

class CachedMethod:
Expand All @@ -67,17 +77,37 @@ class CachedMethod:
typed: Incomplete
key_func: Incomplete
bound_to: Incomplete
def __init__(self, func, cache, scoped: bool = True, typed: bool = False, key: Incomplete | None = None): ...
def __init__(
self,
func,
cache: Mapping[Any, Any] | Callable[..., Incomplete],
scoped: bool = True,
typed: bool = False,
key: Callable[..., Incomplete] | None = None,
): ...
def __get__(self, obj, objtype: Incomplete | None = None): ...
def __call__(self, *args, **kwargs): ...

def cached(cache: Mapping[Any, Any], scoped: bool = True, typed: bool = False, key: Incomplete | None = None): ...
def cachedmethod(cache, scoped: bool = True, typed: bool = False, key: Incomplete | None = None): ...
def cached(
cache: Mapping[Any, Any] | Callable[..., Incomplete],
scoped: bool = True,
typed: bool = False,
key: Callable[..., Incomplete] | None = None,
): ...
def cachedmethod(
cache: Mapping[Any, Any] | Callable[..., Incomplete],
scoped: bool = True,
typed: bool = False,
key: Callable[..., Incomplete] | None = None,
): ...

class cachedproperty(Generic[_T]):
func: Callable[[Incomplete], _T]
def __init__(self, func: Callable[[Incomplete], _T]) -> None: ...
def __get__(self, obj: _T, objtype: type | None = None): ...
class cachedproperty(Generic[_KT, _VT]):
func: Callable[[_KT], _VT]
def __init__(self, func: Callable[[_KT], _VT]) -> None: ...
@overload
def __get__(self, obj: None, objtype: type | None = None) -> Self: ...
@overload
def __get__(self, obj: _KT, objtype: type | None = None) -> _VT: ...

class ThresholdCounter(Generic[_T]):
total: int
Expand All @@ -103,8 +133,8 @@ class ThresholdCounter(Generic[_T]):
def update(self, iterable: Iterable[_T] | Mapping[_T, int], **kwargs: Iterable[_T] | Mapping[_T, int]) -> None: ...

class MinIDMap(Generic[_T]):
mapping: weakref.WeakKeyDictionary[_T, int]
ref_map: dict[_T, int]
mapping: weakref.WeakKeyDictionary[_T, tuple[int, weakref.ReferenceType[_T]]]
ref_map: dict[weakref.ReferenceType[_T], int]
free: list[int]
def __init__(self) -> None: ...
def get(self, a: _T) -> int: ...
Expand Down
53 changes: 33 additions & 20 deletions stubs/boltons/boltons/dictutils.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from _typeshed import SupportsKeysAndGetItem
from binascii import Incomplete
from collections.abc import Generator, ItemsView, Iterable, KeysView, ValuesView
from typing import NoReturn, TypeVar
from typing import NoReturn, TypeVar, overload
from typing_extensions import Self, TypeAlias

_KT = TypeVar("_KT")
Expand All @@ -13,26 +12,32 @@ class OrderedMultiDict(dict[_KT, _VT]):
def addlist(self, k: _KT, v: Iterable[_VT]) -> None: ...
def clear(self) -> None: ...
def copy(self) -> Self: ...
def counts(self) -> OrderedMultiDict[_KT, _VT]: ...
def counts(self) -> Self: ...
@classmethod
def fromkeys(cls, keys: _KT, default: _VT | None = None) -> OrderedMultiDict[_KT, _VT]: ... # type: ignore[override]
def get(self, k: _KT, default: _VT | None = None) -> OrderedMultiDict[_KT, _VT]: ... # type: ignore[override]
def getlist(self, k: _KT, default: _VT | None = ...) -> list[object]: ...
def inverted(self) -> OrderedMultiDict[_KT, _VT]: ...
def fromkeys(cls, keys: _KT, default: _VT | None = None) -> Self: ... # type: ignore[override]
@overload # type: ignore[override]
def get(self, k: _KT, default: None = None) -> _VT | None: ...
@overload
def get(self, k: _KT, default: _VT) -> _VT: ...
def getlist(self, k: _KT, default: list[_VT] = ...) -> list[_VT]: ...
def inverted(self) -> Self: ...
def items(self, multi: bool = False) -> list[tuple[_KT, _VT]]: ... # type: ignore[override]
def iteritems(self, multi: bool = False) -> Generator[tuple[_KT, _VT], None, None]: ...
def iterkeys(self, multi: bool = False) -> Generator[_KT, None, None]: ...
def itervalues(self, multi: bool = False) -> Generator[_VT, None, None]: ...
def keys(self, multi: bool = False) -> list[_KT]: ... # type: ignore[override]
def pop(self, k: _KT, default: _VT | None = ...) -> _VT: ... # type: ignore[override]
def popall(self, k: _KT, default: _VT | None = ...) -> list[_VT]: ...
def poplast(self, k: _KT | None = ..., default: _VT | None = ...) -> _VT: ...
def setdefault(self, k: _KT, default: _VT | None = ...) -> _VT: ...
def sorted(self, key: _KT | None = None, reverse: bool = False) -> OrderedMultiDict[_KT, _VT]: ...
def sortedvalues(self, key: _KT | None = None, reverse: bool = False) -> OrderedMultiDict[_KT, _VT]: ...
def pop(self, k: _KT, default: _VT = ...) -> _VT: ... # type: ignore[override]
def popall(self, k: _KT, default: _VT = ...) -> list[_VT]: ...
def poplast(self, k: _KT = ..., default: _VT = ...) -> _VT: ...
@overload # type: ignore[override]
def setdefault(self, k: _KT, default: None = ...) -> _VT | None: ...
@overload
def setdefault(self, k: _KT, default: _VT) -> _VT: ...
def sorted(self, key: _KT | None = None, reverse: bool = False) -> Self: ...
def sortedvalues(self, key: _KT | None = None, reverse: bool = False) -> Self: ...
def todict(self, multi: bool = False) -> dict[_KT, _VT]: ...
def update(self, E: dict[_KT, _VT] | Iterable[object], **F) -> None: ... # type: ignore[override]
def update_extend(self, E: dict[_KT, _VT] | Iterable[object], **F) -> None: ...
def update(self, E: SupportsKeysAndGetItem[_KT, _VT] | Iterable[tuple[_KT, _VT]], **F) -> None: ... # type: ignore[override]
def update_extend(self, E: SupportsKeysAndGetItem[_KT, _VT] | Iterable[tuple[_KT, _VT]], **F) -> None: ...
def values(self, multi: bool = False) -> list[_VT]: ... # type: ignore[override]
def viewitems(self) -> ItemsView[_KT, _VT]: ...
def viewkeys(self) -> KeysView[_KT]: ...
Expand All @@ -46,7 +51,7 @@ class FastIterOrderedMultiDict(OrderedMultiDict[_KT, _VT]): # undocumented
def iterkeys(self, multi: bool = False) -> Generator[_KT, None, None]: ...

class OneToOne(dict[_KT, _VT]):
inv: dict[_VT, _KT]
inv: OneToOne[_VT, _KT]
def clear(self) -> None: ...
def copy(self) -> Self: ...
def pop(self, key: _KT, default: _VT | _T = ...) -> _VT | _T: ...
Expand All @@ -63,7 +68,9 @@ class ManyToMany(dict[_KT, frozenset[_VT]]):
def __delitem__(self, key: _KT) -> None: ...
def __eq__(self, other): ...
def __getitem__(self, key: _KT): ...
def __init__(self, items: Iterable[Incomplete] | None = None) -> None: ...
def __init__(
self, items: ManyToMany[_KT, _VT] | SupportsKeysAndGetItem[_KT, _VT] | tuple[_KT, _VT] | None = None
) -> None: ...
def __iter__(self): ...
def __len__(self): ...
def __setitem__(self, key: _KT, vals: Iterable[_VT]) -> None: ...
Expand All @@ -81,10 +88,16 @@ class FrozenHashError(TypeError): ... # undocumented

class FrozenDict(dict[_KT, _VT]):
def __copy__(self) -> Self: ...
def clear(self, *a, **kw) -> None: ...
@classmethod
def fromkeys(cls, keys: Iterable[_KT], value: _VT | None = None) -> FrozenDict[_KT, _VT]: ... # type: ignore[override]
def fromkeys(cls, keys: Iterable[_KT], value: _VT | None = None) -> Self: ... # type: ignore[override]
def updated(self, *a, **kw) -> Self: ...
# Can't noqa because of https://github.com/plinss/flake8-noqa/pull/30
# Signature conflicts with superclass, so let's just omit it
# def __ior__(self, *a, **kw) -> NoReturn: ...
def __setitem__(self, *a, **kw) -> NoReturn: ...
def __delitem__(self, *a, **kw) -> NoReturn: ...
def update(self, *a, **kw) -> NoReturn: ...
def pop(self, *a, **kw) -> NoReturn: ...
def popitem(self, *a, **kw) -> NoReturn: ...
def setdefault(self, *a, **kw) -> NoReturn: ...
def updated(self, *a, **kw) -> Self: ...
def clear(self, *a, **kw) -> NoReturn: ...
24 changes: 16 additions & 8 deletions stubs/boltons/boltons/fileutils.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from _typeshed import StrOrBytesPath
from _typeshed import BytesPath, StrOrBytesPath, StrPath
from collections.abc import Callable, Generator, Iterable
from os import PathLike
from types import TracebackType
from typing import IO, Any, NoReturn
from typing import IO, Any, NoReturn, TypeVar, overload
from typing_extensions import Self

_StrPathT = TypeVar("_StrPathT", bound=StrPath)
_BytesPathT = TypeVar("_BytesPathT", bound=BytesPath)

def mkdir_p(path: StrOrBytesPath) -> None: ...
def rotate_file(filename: PathLike[str], *, keep: int = 5) -> None: ...

Expand All @@ -24,9 +27,9 @@ def atomic_save(dest_path: str, **kwargs) -> AtomicSaver: ...
class AtomicSaver:
dest_path: str
overwrite: bool
file_perms: int
file_perms: int | None
overwrite_part: bool
part_filename: str
part_filename: str | None
rm_part_on_exc: bool
text_mode: bool
buffering: int
Expand All @@ -49,17 +52,22 @@ def iter_find_files(
include_dirs: bool = False,
max_depth: int | None = None,
) -> Generator[str, None, None]: ...
@overload
def copy_tree(
src: _StrPathT, dst: _StrPathT, symlinks: bool = False, ignore: Callable[[_StrPathT, list[str]], Iterable[str]] | None = None
) -> None: ...
@overload
def copy_tree(
src: StrOrBytesPath,
dst: StrOrBytesPath,
src: _BytesPathT,
dst: _BytesPathT,
symlinks: bool = False,
ignore: None | Callable[[str, list[str]], Iterable[str]] | Callable[[StrOrBytesPath, list[str]], Iterable[str]] = None,
ignore: Callable[[_BytesPathT, list[bytes]], Iterable[bytes]] | None = None,
) -> None: ...

copytree = copy_tree

class DummyFile:
name: str
name: StrOrBytesPath
mode: str
closed: bool
errors: None
Expand Down
18 changes: 10 additions & 8 deletions stubs/boltons/boltons/formatutils.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from collections.abc import Callable
from typing import Any
from typing import Generic, TypeVar

def construct_format_field_str(fname: str, fspec: str, conv: str) -> str: ...
_T = TypeVar("_T")

def construct_format_field_str(fname: str | None, fspec: str | None, conv: str | None) -> str: ...
def infer_positional_format_args(fstr: str) -> str: ...
def get_format_args(fstr: str) -> tuple[list[tuple[int, type]], list[tuple[str, type]]]: ...
def tokenize_format_str(fstr: str, resolve_pos: bool = True) -> list[str | BaseFormatField]: ...
Expand All @@ -18,17 +20,17 @@ class BaseFormatField:
type_char: str
type_func: str
def set_fspec(self, fspec) -> None: ...
conv: str
conv: str | None
conv_func: str | None
def set_conv(self, conv: str) -> None: ...
def set_conv(self, conv: str | None) -> None: ...
@property
def fstr(self) -> str: ...

class DeferredValue:
func: Callable[..., Any]
class DeferredValue(Generic[_T]):
func: Callable[[], _T]
cache_value: bool
def __init__(self, func: Callable[..., Any], cache_value: bool = True) -> None: ...
def get_value(self) -> Any: ...
def __init__(self, func: Callable[[], _T], cache_value: bool = True) -> None: ...
def get_value(self) -> _T: ...
def __int__(self) -> int: ...
def __float__(self) -> float: ...
def __unicode__(self) -> str: ...
Expand Down
13 changes: 5 additions & 8 deletions stubs/boltons/boltons/listutils.pyi
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
from collections.abc import Iterable
from typing import SupportsIndex, TypeVar, overload
from typing import SupportsIndex, TypeVar
from typing_extensions import Self, TypeAlias

_T = TypeVar("_T")

class BarrelList(list[_T]):
lists: list[list[_T]]
@overload
def __init__(self, iterable: None = None) -> None: ...
@overload
def __init__(self, iterable: Iterable[_T]) -> None: ...
def __init__(self, iterable: Iterable[_T] | None = None) -> None: ...
def insert(self, index: SupportsIndex, item: _T) -> None: ...
def append(self, item: _T) -> None: ...
def extend(self, iterable: Iterable[_T]) -> None: ...
def pop(self, *a) -> _T: ...
def iter_slice(self, start: int, stop: int, step: int | None = None) -> Iterable[_T]: ...
def iter_slice(self, start: int | None, stop: int | None, step: int | None = None) -> Iterable[_T]: ...
def del_slice(self, start: int, stop: int, step: int | None = None) -> None: ...
__delslice__ = del_slice
@classmethod
def from_iterable(cls, it: Iterable[_T]) -> Self: ...
def __getslice__(self, start: int, stop: int): ...
def __setslice__(self, start: int, stop: int, sequence: int) -> None: ...
def __setslice__(self, start: SupportsIndex, stop: SupportsIndex, sequence: Iterable[_T]) -> None: ...
def sort(self) -> None: ... # type: ignore[override]
def reverse(self) -> None: ...
def count(self, item: _T) -> int: ...
Expand All @@ -30,4 +27,4 @@ BList: TypeAlias = BarrelList[_T]

class SplayList(list[_T]):
def shift(self, item_index: int, dest_index: int = 0) -> None: ...
def swap(self, item_index: int, dest_index: int) -> None: ...
def swap(self, item_index: SupportsIndex, dest_index: SupportsIndex) -> None: ...
13 changes: 10 additions & 3 deletions stubs/boltons/boltons/mathutils.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
from collections.abc import Sequence
from collections.abc import Iterable
from typing import overload

def clamp(x: float, lower: float = ..., upper: float = ...) -> float: ...
def ceil(x: float, options: Sequence[float] | None = None) -> float: ...
def floor(x: float, options: Sequence[float] | None = None) -> float: ...
@overload
def ceil(x: float, options: None = None) -> int: ...
@overload
def ceil(x: float, options: Iterable[float]) -> float: ...
@overload
def floor(x: float, options: None = None) -> int: ...
@overload
def floor(x: float, options: Iterable[float]) -> float: ...

class Bits:
val: int
Expand Down
11 changes: 10 additions & 1 deletion stubs/boltons/boltons/mboxutils.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import mailbox
from _typeshed import StrPath
from collections.abc import Callable
from typing import IO, Any

DEFAULT_MAXMEM: int

class mbox_readonlydir(mailbox.mbox):
maxmem: int
def __init__(self, path: str, factory: type | None = None, create: bool = True, maxmem: int = 1048576) -> None: ...
def __init__(
self,
path: StrPath,
factory: Callable[[IO[Any]], mailbox.mboxMessage] | None = None,
create: bool = True,
maxmem: int = 1048576,
) -> None: ...
def flush(self) -> None: ...
6 changes: 3 additions & 3 deletions stubs/boltons/boltons/namedutils.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections.abc import Sequence
from collections.abc import Iterable

def namedtuple(typename: str, field_names: Sequence[str], verbose: bool = False, rename: bool = False): ...
def namedlist(typename: str, field_names: Sequence[str], verbose: bool = False, rename: bool = False): ...
def namedtuple(typename: str, field_names: str | Iterable[str], verbose: bool = False, rename: bool = False): ...
def namedlist(typename: str, field_names: str | Iterable[str], verbose: bool = False, rename: bool = False): ...
8 changes: 5 additions & 3 deletions stubs/boltons/boltons/pathutils.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from _typeshed import StrPath

def augpath(
path: str,
path: StrPath,
suffix: str = "",
prefix: str = "",
ext: str | None = None,
base: str | None = None,
dpath: str | None = None,
multidot: bool = False,
) -> str: ...
def shrinkuser(path: str, home: str = "~") -> str: ...
def expandpath(path: str) -> str: ...
def shrinkuser(path: StrPath, home: str = "~") -> str: ...
def expandpath(path: StrPath) -> str: ...
Loading