Skip to content

Commit eeff25e

Browse files
committed
Remove boltons dependencies
1 parent 9021274 commit eeff25e

6 files changed

Lines changed: 24 additions & 35 deletions

File tree

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ keywords =
3232
package_dir =
3333
= src
3434
install_requires =
35-
boltons
3635
dill
3736
tqdm
3837
numpy

src/dryml/core2/definition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def skip_args(self) -> bool:
135135
else:
136136
return False
137137

138-
# --- mapping interface (for get_definition_view / remap compatibility) ---
138+
# --- mapping interface (for view compatibility) ---
139139
def __getitem__(self, k: str) -> Any:
140140
if k == "cls":
141141
if self._cls is None:

src/dryml/core2/freeze.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ def __repr__(self) -> str:
4242

4343
class FrozenDict(ABCMapping):
4444
"""
45-
Immutable mapping, not a dict subclass (important: boltons.remap default_enter
46-
will build a plain dict for dictlikes, avoiding 'can’t populate an immutable dict').
45+
Immutable mapping, not a dict subclass
4746
"""
4847
__slots__ = ("_items", "_dict")
4948

src/dryml/core2/repo.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -776,33 +776,6 @@ def _add_object(obj: Any):
776776
for arg in args:
777777
_add_object(arg)
778778

779-
780-
# def _enter(path, key, value):
781-
# if isinstance(value, Object):
782-
# return {}, get_object_view(value)
783-
# elif isinstance(value, ConcreteDefinition):
784-
# return {}, get_definition_view(value)
785-
# else:
786-
# return default_enter(path, key, value)
787-
788-
# def _exit(path, key, value, new_parent, new_items):
789-
# if isinstance(value, Object):
790-
# _add_object(value)
791-
# return value
792-
# elif isinstance(value, ConcreteDefinition):
793-
# if value._obj is None:
794-
# raise ValueError("Can't use a ConcreteDefinition without _obj pointer..")
795-
# _add_object(value._obj)
796-
# return value._obj
797-
# else:
798-
# return default_exit(path, key, value, new_parent, new_items)
799-
800-
# remap(
801-
# args,
802-
# enter=_enter,
803-
# visit=default_visit,
804-
# exit=_exit)
805-
806779
def flush(self):
807780
# Commit all stores
808781
for store in self.stores:

src/dryml/core2/utils/general.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import io
99
import glob
1010
from typing import Optional, Callable
11-
from collections.abc import Mapping, ItemsView
11+
from collections.abc import Mapping, Iterable, ItemsView
1212
from inspect import getmodule, isclass, \
1313
Parameter, signature
1414

@@ -85,6 +85,26 @@ def is_dictlike(val):
8585
return isinstance(val, Mapping)
8686

8787

88+
def is_collection(val) -> bool:
89+
"""
90+
True for non-mapping iterables (lists, tuples, sets, generators, etc.),
91+
but False for string/bytes-like objects and mappings.
92+
"""
93+
if val is None:
94+
return False
95+
96+
# Treat these as scalars/leaves, not collections
97+
if isinstance(val, (str, bytes, bytearray, memoryview)):
98+
return False
99+
100+
# Leave mappings to is_dictlike()
101+
if isinstance(val, Mapping):
102+
return False
103+
104+
# Iterable => collection
105+
return isinstance(val, Iterable)
106+
107+
88108
def is_stream(obj) -> bool:
89109
return isinstance(obj, io.IOBase)
90110

src/dryml/core2/utils/stable_hash.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99

1010
import numpy as np
1111

12-
from .general import is_dictlike
12+
from .general import is_dictlike, is_collection
1313
from .recurse import cycle_detect
14-
from boltons.iterutils import remap, is_collection, default_enter
1514

1615
def stable_int_hash(s: str, *, bits: int = 64) -> int:
1716
# blake2b is fast and stable; digest_size controls output size
@@ -121,7 +120,6 @@ def stable_hash_value(value) -> str:
121120

122121
def _is_container(value) -> bool:
123122
"""
124-
Container in the sense of remap traversal.
125123
Note: np.ndarray is explicitly *not* treated as a container here.
126124
"""
127125
return (is_dictlike(value) or is_collection(value)) and not isinstance(value, np.ndarray)

0 commit comments

Comments
 (0)