|  | 
| 19 | 19 | from named import get_type_name | 
| 20 | 20 | from typing_aliases import AnySet, is_instance, is_sized, is_slice | 
| 21 | 21 | from typing_extensions import TypeIs | 
| 22 |  | -from wraps.wraps import wrap_option | 
|  | 22 | +from wraps.wraps.option import wrap_option_on | 
| 23 | 23 | 
 | 
| 24 | 24 | __all__ = ("OrderedSet", "ordered_set", "ordered_set_unchecked") | 
| 25 | 25 | 
 | 
| @@ -49,6 +49,9 @@ def is_any_set(iterable: Iterable[T]) -> TypeIs[AnySet[T]]: | 
| 49 | 49 |     return is_instance(iterable, AnySet) | 
| 50 | 50 | 
 | 
| 51 | 51 | 
 | 
|  | 52 | +wrap_index_error = wrap_option_on(IndexError) | 
|  | 53 | + | 
|  | 54 | + | 
| 52 | 55 | class OrderedSet(MutableSet[Q], Sequence[Q]): | 
| 53 | 56 |     """Represents ordered sets, i.e. mutable hash sets that preserve insertion order. | 
| 54 | 57 | 
 | 
| @@ -350,7 +353,7 @@ def index(self, item: Q, start: Optional[int] = None, stop: Optional[int] = None | 
| 350 | 353 | 
 | 
| 351 | 354 |         return index | 
| 352 | 355 | 
 | 
| 353 |  | -    get_index = wrap_option(index) | 
|  | 356 | +    get_index = wrap_index_error(index) | 
| 354 | 357 |     """An alias of [`index`][iters.ordered_set.OrderedSet.index] wrapped to return | 
| 355 | 358 |     [`Option[int]`][wraps.option.Option] instead of erroring. | 
| 356 | 359 |     """ | 
| @@ -405,7 +408,7 @@ def pop(self, index: int = LAST) -> Q: | 
| 405 | 408 | 
 | 
| 406 | 409 |         return item | 
| 407 | 410 | 
 | 
| 408 |  | -    get_pop = wrap_option(pop) | 
|  | 411 | +    get_pop = wrap_index_error(pop) | 
| 409 | 412 |     """An alias of [`pop`][iters.ordered_set.OrderedSet.pop] wrapped to return | 
| 410 | 413 |     [`Option[Q]`][wraps.option.Option] instead of erroring. | 
| 411 | 414 |     """ | 
|  | 
0 commit comments