Skip to content
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

Refactor Wraps Usage #66

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

<!-- changelogging: start -->

## 0.19.0 (2024-10-02)

### Changes

- Migrated to the latest version of the `wraps` library.

## 0.18.0 (2024-04-23)

### Changes
Expand Down
8 changes: 5 additions & 3 deletions iters/async_iters.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@
)
from typing_extensions import Never, ParamSpec
from wraps.early.decorators import early_option_await
from wraps.primitives.option import Option, Some
from wraps.primitives.result import Result
from wraps.wraps.futures import wrap_future, wrap_future_option, wrap_future_result
from wraps.option import Option, Some
from wraps.result import Result
from wraps.futures.future import wrap_future
from wraps.futures.option import wrap_future_option
from wraps.futures.result import wrap_future_result

from iters.async_utils import (
async_accumulate_fold,
Expand Down
10 changes: 5 additions & 5 deletions iters/async_wraps.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import AsyncIterator, TypeVar

from typing_aliases import AnyIterable, AsyncBinary, AsyncUnary, Binary, Unary
from wraps.primitives.option import NULL, Option, Some
from wraps.primitives.result import Error, Ok, Result
from wraps.option import NULL, Option, Some
from wraps.result import Err, Ok, Result

from iters.async_utils import async_chain, async_iter, async_next_unchecked
from iters.types import is_marker, marker
Expand Down Expand Up @@ -64,12 +64,12 @@ async def async_exactly_one(iterable: AnyIterable[T]) -> Result[T, Option[AsyncI
first = await async_next_unchecked(iterator, marker)

if is_marker(first):
return Error(NULL)
return Err(NULL)

second = await async_next_unchecked(iterator, marker)

if not is_marker(second):
return Error(Some(async_chain((first, second), iterator)))
return Err(Some(async_chain((first, second), iterator)))

return Ok(first)

Expand All @@ -85,6 +85,6 @@ async def async_at_most_one(iterable: AnyIterable[T]) -> Result[Option[T], Async
second = await async_next_unchecked(iterator, marker)

if not is_marker(second):
return Error(async_chain((first, second), iterator))
return Err(async_chain((first, second), iterator))

return Ok(Some(first))
4 changes: 2 additions & 2 deletions iters/iters.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
)
from typing_extensions import Never, ParamSpec
from wraps.early.decorators import early_option
from wraps.primitives.option import Option, Some
from wraps.primitives.result import Result
from wraps.option import Option, Some
from wraps.result import Result

from iters.constants import DEFAULT_START, DEFAULT_STEP, EMPTY_BYTES, EMPTY_STRING
from iters.ordered_set import OrderedSet, ordered_set
Expand Down
2 changes: 1 addition & 1 deletion iters/mapping_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from attrs import frozen
from typing_extensions import Self
from wraps.wraps.option import wrap_option_on
from wraps.option import wrap_option_on

__all__ = ("MappingView", "mapping_view")

Expand Down
2 changes: 1 addition & 1 deletion iters/ordered_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from named import get_type_name
from typing_aliases import AnySet, is_instance, is_sized, is_slice
from typing_extensions import TypeIs
from wraps.wraps.option import wrap_option_on
from wraps.option import wrap_option_on

__all__ = ("OrderedSet", "ordered_set", "ordered_set_unchecked")

Expand Down
2 changes: 1 addition & 1 deletion iters/sequence_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from attrs import frozen
from typing_aliases import is_slice
from wraps.wraps.option import wrap_option_on
from wraps.option import wrap_option_on

__all__ = ("SequenceView", "sequence_view")

Expand Down
2 changes: 1 addition & 1 deletion iters/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from solus import Singleton
from typing_extensions import TypeIs
from wraps.primitives.option import NULL, Option, Some
from wraps.option import NULL, Option, Some

T = TypeVar("T")

Expand Down
10 changes: 5 additions & 5 deletions iters/wraps.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Iterable, Iterator, TypeVar

from typing_aliases import Binary, Unary
from wraps.primitives.option import NULL, Option, Some
from wraps.primitives.result import Error, Ok, Result
from wraps.option import NULL, Option, Some
from wraps.result import Err, Ok, Result

from iters.types import is_marker, marker
from iters.utils import chain
Expand Down Expand Up @@ -37,12 +37,12 @@ def exactly_one(iterable: Iterable[T]) -> Result[T, Option[Iterator[T]]]:
first = next(iterator, marker)

if is_marker(first):
return Error(NULL)
return Err(NULL)

second = next(iterator, marker)

if not is_marker(second):
return Error(Some(chain((first, second), iterator)))
return Err(Some(chain((first, second), iterator)))

return Ok(first)

Expand All @@ -58,6 +58,6 @@ def at_most_one(iterable: Iterable[T]) -> Result[Option[T], Iterator[T]]:
second = next(iterator, marker)

if not is_marker(second):
return Error(chain((first, second), iterator))
return Err(chain((first, second), iterator))

return Ok(Some(first))
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async-extensions = ">= 4.0.0"
mixed-methods = ">= 1.1.1"

funcs = ">= 0.10.1"
wraps = ">= 0.11.0"
wraps = ">= 0.15.0"

[tool.poetry.group.format.dependencies]
ruff = "0.4.1"
Expand Down