Skip to content

add boltons #8892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 68 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
9680e81
update gitignore
AABur Oct 12, 2022
a6800a3
add auto-generated stubs for boltons
AABur Oct 12, 2022
ede7ad0
update dictutils/FrozenDict
AABur Oct 13, 2022
0d7f4ff
update dictutils/FrozenHashError
AABur Oct 13, 2022
d40ab5d
update dictutils/subdict
AABur Oct 13, 2022
04ab8fd
update dictutils/ManyToMany
AABur Oct 13, 2022
24c1590
update dictutils/OneToOne
AABur Oct 13, 2022
0c90a6e
update dictutils/FastIterOrderedMultiDict
AABur Oct 13, 2022
76b5e8b
update dictutils/OrderedMultiDict
AABur Oct 13, 2022
af3dbb9
format code
AABur Oct 13, 2022
f120ae7
fix linter warnings
AABur Oct 15, 2022
9ee21c5
fix linter warnings
AABur Oct 16, 2022
b6d5968
Merge branch 'python:master' into boltons
AABur Oct 27, 2022
416ba9c
Make changes to pass flake8 (#2)
amaslenn Oct 27, 2022
007b6d1
Merge branch 'python:main' into boltons
AABur Nov 11, 2022
2155b12
boltons: fix stubtest errors
AABur Nov 11, 2022
211c8d0
remove unused allowlist entry
AlexWaygood Nov 11, 2022
155c216
Merge branch 'python:main' into boltons
AABur Nov 12, 2022
339528c
boltons: queueutils realised
AABur Nov 12, 2022
25400e7
Merge branch 'python:main' into boltons
AABur Nov 12, 2022
0d63389
boltons: type annotations updated
AABur Nov 13, 2022
b4e0a7d
Merge branch 'python:main' into boltons
AABur Nov 13, 2022
f372c6c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 13, 2022
f51cdc6
boltons: fix pathutils
AABur Nov 13, 2022
4efb652
Merge branch 'python:main' into boltons
AABur Nov 14, 2022
d0e2679
Merge branch 'python:main' into boltons
AABur Nov 15, 2022
dc972ad
Merge branch 'python:main' into boltons
AABur Nov 17, 2022
1ebd17f
fix subtest errors
AABur Nov 18, 2022
13bd8da
boltons: ecoutils - fix stubtest errors
AABur Nov 22, 2022
8dd781b
boltons: annotated - cacheutils, fileutils, formatutils, statsutils, …
AABur Nov 22, 2022
ba7843e
Merge branch 'python:main' into boltons
AABur Nov 22, 2022
dc819d4
boltons(cacheutils): fix pyright errors
AABur Nov 22, 2022
f661197
boltons(ecoutils): fix stubtest errors
AABur Nov 22, 2022
d58eefa
boltons(ecoutils): fexed
AABur Nov 26, 2022
fff4362
Merge branch 'python:main' into boltons
AABur Nov 26, 2022
ed0633e
boltons: fix flake8 errors
AABur Nov 26, 2022
3c35bb5
boltons: fix allowlist
AABur Nov 26, 2022
6725d86
boltons: types annotated for dictutils, fileutils, gcutils, mathutils…
AABur Nov 27, 2022
7d80804
boltons(ecoutils): updated
AABur Nov 27, 2022
bff5263
boltons: fix stubtest_allowlist
AABur Nov 27, 2022
a7a969c
Fiddle with stubtest allowlist
AlexWaygood Dec 11, 2022
3c50398
Fix `ecotutils.getrandbits`
AlexWaygood Dec 12, 2022
399716c
Merge branch 'main' into boltons
AlexWaygood Dec 12, 2022
e24405a
remove commented-out code and unneeded TODO
AABur Dec 21, 2022
3a4de5e
Merge branch 'python:main' into boltons
AABur Jan 1, 2023
7a8811f
Merge branch 'python:main' into boltons
AABur Mar 22, 2023
0948b5c
boltons.debugutils updated
AABur Jan 1, 2023
048783f
Merge branch 'python:main' into boltons
AABur Mar 22, 2023
ad6c2ab
Merge branch 'python:main' into boltons
AABur Mar 29, 2023
0a5b40c
update `casheutils` and `debugutils`
AABur Mar 30, 2023
e044708
fix `debugutils`
AABur Mar 30, 2023
b63f681
update dictutils
AABur Mar 30, 2023
3fe149d
fix `cacheutils` and `dictutils`
AABur Mar 30, 2023
cff28a5
update listutils
AABur Mar 31, 2023
abb2d21
update listutils
AABur Mar 31, 2023
019b6a9
update tbutils and typeutils
AABur Mar 31, 2023
a536c53
update dictutils and tbutils
AABur Apr 1, 2023
69e8767
update `setutils` and `socketutils`
AABur Apr 9, 2023
f48d187
boltons: update `cacheutils`
AABur May 17, 2023
ef5c948
Merge branch 'main' into boltons
AABur May 18, 2023
9d1128c
Many fixes
JelleZijlstra Jun 7, 2023
5cfc655
Merge remote-tracking branch 'upstream/main' into boltons
JelleZijlstra Jun 7, 2023
f60417c
black
JelleZijlstra Jun 7, 2023
700ab61
stubdefaulter
JelleZijlstra Jun 7, 2023
f7b8936
black
JelleZijlstra Jun 7, 2023
c83e076
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 7, 2023
de2d52a
Some mypy fixes
JelleZijlstra Jun 7, 2023
8479b28
stubtest fixes
JelleZijlstra Jun 7, 2023
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ analyze.py

# Mypy cache
.mypy_cache/

# pyenv local python version
.python-version
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"stubs/bleach",
"stubs/boto",
"stubs/beautifulsoup4",
"stubs/boltons",
"stubs/braintree",
"stubs/caldav",
"stubs/cffi",
Expand Down
10 changes: 10 additions & 0 deletions stubs/boltons/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# These names exist in __all__, but have no definition:
boltons.strutils.int_list_complement
boltons.strutils.int_list_to_int_tuples

# Internal compatibility aliases
boltons.cacheutils.basestring
boltons.funcutils.basestring
boltons.funcutils.inspect_formatargspec
boltons.funcutils.make_method
boltons.iterutils.basestring
4 changes: 4 additions & 0 deletions stubs/boltons/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version = "23.0.*"

[tool.stubtest]
ignore_missing_stub = false
Empty file.
115 changes: 115 additions & 0 deletions stubs/boltons/boltons/cacheutils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import weakref
from _typeshed import Incomplete, Self, SupportsItems, SupportsKeysAndGetItem
from collections.abc import Callable, Generator, Hashable, Iterable, Iterator, Mapping
from typing import Any, Generic, TypeVar, overload

_KT = TypeVar("_KT")
_VT = TypeVar("_VT")
_T = TypeVar("_T")

PREV: int
NEXT: int
KEY: int
VALUE: int
DEFAULT_MAX_SIZE: int

class LRI(dict[_KT, _VT]):
hit_count: int
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: ...
def __setitem__(self, key: _KT, value: _VT) -> None: ...
def __getitem__(self, key: _KT) -> _VT: ...
@overload
def get(self, key: _KT, default: None = None) -> _VT | None: ...
@overload
def get(self, key: _KT, default: _T) -> _T | _VT: ...
def __delitem__(self, key: _KT) -> None: ...
@overload
def pop(self, key: _KT) -> _VT: ...
@overload
def pop(self, key: _KT, default: _T) -> _T | _VT: ...
def popitem(self) -> tuple[_KT, _VT]: ...
def clear(self) -> None: ...
def copy(self: Self) -> Self: ...
@overload
def setdefault(self, key: _KT, default: None = None) -> _VT: ...
@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]

class LRU(LRI[_KT, _VT]):
def __getitem__(self, key: _KT) -> _VT: ...

def make_cache_key(
args: Iterable[Hashable],
kwargs: SupportsItems[Hashable, Hashable],
typed: bool = False,
kwarg_mark: object = ...,
fasttypes: frozenset[type] = ...,
): ...

class CachedFunction:
func: Incomplete
get_cache: Incomplete
scoped: Incomplete
typed: Incomplete
key_func: Incomplete
def __init__(self, func, cache, scoped: bool = True, typed: bool = False, key: Incomplete | None = None): ...
def __call__(self, *args, **kwargs): ...

class CachedMethod:
func: Incomplete
get_cache: Incomplete
scoped: Incomplete
typed: Incomplete
key_func: Incomplete
bound_to: Incomplete
def __init__(self, func, cache, scoped: bool = True, typed: bool = False, key: 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): ...

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 ThresholdCounter(Generic[_T]):
total: int
def __init__(self, threshold: float = 0.001) -> None: ...
@property
def threshold(self) -> float: ...
def add(self, key: _T) -> None: ...
def elements(self) -> Iterator[_T]: ...
def most_common(self, n: int | None = None) -> list[tuple[_T, int]]: ...
def get_common_count(self) -> int: ...
def get_uncommon_count(self) -> int: ...
def get_commonality(self) -> float: ...
def __getitem__(self, key: _T) -> int: ...
def __len__(self) -> int: ...
def __contains__(self, key: _T) -> bool: ...
def iterkeys(self) -> Iterator[_T]: ...
def keys(self) -> list[_T]: ...
def itervalues(self) -> Generator[int, None, None]: ...
def values(self) -> list[int]: ...
def iteritems(self) -> Generator[tuple[_T, int], None, None]: ...
def items(self) -> list[tuple[_T, int]]: ...
def get(self, key: _T, default: int = 0) -> int: ...
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]
free: list[int]
def __init__(self) -> None: ...
def get(self, a: _T) -> int: ...
def drop(self, a: _T) -> None: ...
def __contains__(self, a: _T) -> bool: ...
def __iter__(self) -> Iterator[_T]: ...
def __len__(self) -> int: ...
def iteritems(self) -> Iterator[tuple[_T, int]]: ...
9 changes: 9 additions & 0 deletions stubs/boltons/boltons/debugutils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from _typeshed import Incomplete
from collections.abc import Callable
from typing import Any

def pdb_on_signal(signalnum: int | None = None) -> None: ...
def pdb_on_exception(limit: int = 100) -> None: ...
def wrap_trace(
obj: Incomplete, hook: Callable[..., Any] = ..., which: str | None = None, events: str | None = None, label: str | None = None
) -> Incomplete: ...
8 changes: 8 additions & 0 deletions stubs/boltons/boltons/deprutils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from types import ModuleType
from typing import Any

class DeprecatableModule(ModuleType):
def __init__(self, module: ModuleType) -> None: ...
def __getattribute__(self, name: str) -> Any: ...

def deprecate_module_member(mod_name: str, name: str, message: str) -> None: ...
90 changes: 90 additions & 0 deletions stubs/boltons/boltons/dictutils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
from _typeshed import SupportsKeysAndGetItem
from binascii import Incomplete
from collections.abc import Generator, ItemsView, Iterable, KeysView, ValuesView
from typing import NoReturn, TypeVar
from typing_extensions import Self, TypeAlias

_KT = TypeVar("_KT")
_VT = TypeVar("_VT")
_T = TypeVar("_T")

class OrderedMultiDict(dict[_KT, _VT]):
def add(self, k: _KT, v: _VT) -> None: ...
def addlist(self, k: _KT, v: Iterable[_VT]) -> None: ...
def clear(self) -> None: ...
def copy(self) -> Self: ...
def counts(self) -> OrderedMultiDict[_KT, _VT]: ...
@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 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 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 values(self, multi: bool = False) -> list[_VT]: ... # type: ignore[override]
def viewitems(self) -> ItemsView[_KT, _VT]: ...
def viewkeys(self) -> KeysView[_KT]: ...
def viewvalues(self) -> ValuesView[_VT]: ...

OMD: TypeAlias = OrderedMultiDict[_KT, _VT]
MultiDict: TypeAlias = OrderedMultiDict[_KT, _VT]

class FastIterOrderedMultiDict(OrderedMultiDict[_KT, _VT]): # undocumented
def iteritems(self, multi: bool = False) -> Generator[tuple[_KT, _VT], None, None]: ...
def iterkeys(self, multi: bool = False) -> Generator[_KT, None, None]: ...

class OneToOne(dict[_KT, _VT]):
inv: dict[_VT, _KT]
def clear(self) -> None: ...
def copy(self) -> Self: ...
def pop(self, key: _KT, default: _VT | _T = ...) -> _VT | _T: ...
def popitem(self) -> tuple[_KT, _VT]: ...
def setdefault(self, key: _KT, default: _VT | None = None) -> _VT: ...
@classmethod
def unique(cls, *a, **kw) -> Self: ...
def update(self, dict_or_iterable, **kw) -> None: ... # type: ignore[override]

class ManyToMany(dict[_KT, frozenset[_VT]]):
data: dict[_KT, set[_VT]]
inv: dict[_VT, set[_KT]]
# def __contains__(self, key: _KT): ...
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 __iter__(self): ...
def __len__(self): ...
def __setitem__(self, key: _KT, vals: Iterable[_VT]) -> None: ...
def add(self, key: _KT, val: _VT) -> None: ...
def get(self, key: _KT, default: frozenset[_VT] = ...) -> frozenset[_VT]: ... # type: ignore[override]
def iteritems(self) -> Generator[tuple[_KT, _VT], None, None]: ...
def keys(self): ...
def remove(self, key: _KT, val: _VT) -> None: ...
def replace(self, key: _KT, newkey: _KT) -> None: ...
def update(self, iterable: ManyToMany[_KT, _VT] | SupportsKeysAndGetItem[_KT, _VT] | tuple[_KT, _VT]) -> None: ... # type: ignore[override]

def subdict(d: dict[_KT, _VT], keep: Iterable[_KT] | None = None, drop: Iterable[_KT] | None = None) -> dict[_KT, _VT]: ...

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 pop(self, *a, **kw) -> NoReturn: ...
def popitem(self, *a, **kw) -> NoReturn: ...
def setdefault(self, *a, **kw) -> NoReturn: ...
def updated(self, *a, **kw) -> Self: ...
3 changes: 3 additions & 0 deletions stubs/boltons/boltons/easterutils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import NoReturn

def gobs_program() -> NoReturn: ...
28 changes: 28 additions & 0 deletions stubs/boltons/boltons/ecoutils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from typing import Any

ECO_VERSION: str
PY_GT_2: bool
HAVE_URANDOM: bool
INSTANCE_ID: str
IS_64BIT: bool
HAVE_UCS4: bool
HAVE_READLINE: bool
SQLITE_VERSION: str
OPENSSL_VERSION: str
TKINTER_VERSION: str
ZLIB_VERSION: str
EXPAT_VERSION: str
CPU_COUNT: int
HAVE_THREADING: bool
HAVE_IPV6: bool
RLIMIT_NOFILE: int
RLIMIT_FDS_SOFT: int
RLIMIT_FDS_HARD: int
START_TIME_INFO: dict[str, str | float]

def getrandbits(k: int) -> int: ...
def get_python_info() -> dict[str, Any]: ...
def get_profile(**kwargs) -> dict[str, Any]: ...
def get_profile_json(indent: bool = False) -> str: ...
def main() -> None: ...
def dumps(val: Any, indent: int) -> str: ...
9 changes: 9 additions & 0 deletions stubs/boltons/boltons/excutils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import Any
from typing_extensions import Self

class ExceptionCauseMixin(Exception):
cause: Any
def __new__(cls, *args, **kw) -> Self: ...
def get_str(self) -> str: ...

class MathError(ExceptionCauseMixin, ValueError): ...
79 changes: 79 additions & 0 deletions stubs/boltons/boltons/fileutils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
from _typeshed import StrOrBytesPath
from collections.abc import Callable, Generator, Iterable
from types import TracebackType
from typing import IO, Any, NoReturn
from typing_extensions import Self

def mkdir_p(path: StrOrBytesPath) -> None: ...

class FilePerms:
user: str
group: str
other: str
def __init__(self, user: str = "", group: str = "", other: str = "") -> None: ...
@classmethod
def from_int(cls, i: int) -> Self: ...
@classmethod
def from_path(cls, path: StrOrBytesPath) -> Self: ...
def __int__(self) -> int: ...

def atomic_save(dest_path: str, **kwargs) -> AtomicSaver: ...

class AtomicSaver:
dest_path: str
overwrite: bool
file_perms: int
overwrite_part: bool
part_filename: str
rm_part_on_exc: bool
text_mode: bool
buffering: int
dest_dir: str
part_path: str
mode: str
open_flags: int
part_file: str | None
def __init__(self, dest_path: str, **kwargs) -> None: ...
def setup(self) -> None: ...
def __enter__(self) -> IO[Any] | None: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...

def iter_find_files(
directory: str, patterns: str | Iterable[str], ignored: str | Iterable[str] | None = None, include_dirs: bool = False
) -> Generator[str, None, None]: ...
def copy_tree(
src: StrOrBytesPath,
dst: StrOrBytesPath,
symlinks: bool = False,
ignore: None | Callable[[str, list[str]], Iterable[str]] | Callable[[StrOrBytesPath, list[str]], Iterable[str]] = None,
) -> None: ...

copytree = copy_tree

class DummyFile:
name: str
mode: str
closed: bool
errors: None
isatty: bool
encoding: None
newlines: None
softspace: int
def __init__(self, path: StrOrBytesPath, mode: str = "r", buffering: int | None = None) -> None: ...
def close(self) -> None: ...
def fileno(self) -> int: ...
def flush(self) -> None: ...
def next(self) -> NoReturn: ...
def read(self, size: int = 0) -> str: ...
def readline(self, size: int = 0) -> str: ...
def readlines(self, size: int = 0) -> list[str]: ...
def seek(self) -> None: ...
def tell(self) -> int: ...
def truncate(self) -> None: ...
def write(self, string: str) -> None: ...
def writelines(self, list_of_strings: list[str]) -> None: ...
def __next__(self) -> NoReturn: ...
def __enter__(self) -> None: ...
def __exit__(self, exc_type, exc_val, exc_tb) -> None: ...
Loading