Skip to content

Commit

Permalink
Update views, bump dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
nekitdev committed Jan 6, 2024
1 parent afd2971 commit 4658842
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 51 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Or by directly specifying it in the configuration like so:

```toml
[tool.poetry.dependencies]
iters = "^0.15.0"
iters = "^0.16.0"
```

Alternatively, you can add it directly from the source:
Expand Down
2 changes: 1 addition & 1 deletion iters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
__title__ = "iters"
__author__ = "nekitdev"
__license__ = "MIT"
__version__ = "0.15.0"
__version__ = "0.16.0"

from iters.async_iters import (
AsyncIter,
Expand Down
24 changes: 22 additions & 2 deletions iters/iters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,17 @@ def create_zip_longest(
__iterable_e: Iterable[E],
__iterable_f: Iterable[F],
__iterable_g: Iterable[G],
) -> Iter[Tuple[Option[A], Option[B], Option[C], Option[D], Option[E], Option[F], Option[G],]]:
) -> Iter[
Tuple[
Option[A],
Option[B],
Option[C],
Option[D],
Option[E],
Option[F],
Option[G],
]
]:
...

@overload
Expand Down Expand Up @@ -2626,7 +2636,17 @@ def apply_zip_longest(
__iterable_d: Iterable[D],
__iterable_e: Iterable[E],
__iterable_f: Iterable[F],
) -> Iter[Tuple[Option[T], Option[A], Option[B], Option[C], Option[D], Option[E], Option[F],]]:
) -> Iter[
Tuple[
Option[T],
Option[A],
Option[B],
Option[C],
Option[D],
Option[E],
Option[F],
]
]:
...

@overload
Expand Down
41 changes: 41 additions & 0 deletions iters/mapping_view.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from typing import Any, Iterator, Mapping, TypeVar, final

from attrs import frozen
from typing_extensions import Self
from wraps import wrap_option

__all__ = ("MappingView", "mapping_view")

K = TypeVar("K")
V = TypeVar("V")


@final
@frozen()
class MappingView(Mapping[K, V]):
"""Represents view over mappings."""

mapping: Mapping[K, V]
"""The mapping to view."""

def __iter__(self) -> Iterator[K]:
yield from self.mapping

def __getitem__(self, key: K) -> V:
return self.mapping[key]

def __contains__(self, key: Any) -> bool:
return key in self.mapping

def __len__(self) -> int:
return len(self.mapping)

@wrap_option
def get_option(self, key: K) -> V:
return self[key]

def copy(self) -> Self:
return type(self)(self)


mapping_view = MappingView
9 changes: 2 additions & 7 deletions iters/sequence_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
__all__ = ("SequenceView", "sequence_view")

T = TypeVar("T")
U = TypeVar("U")


@final
Expand All @@ -18,11 +17,7 @@ class SequenceView(Sequence[T]):
"""Represents views over sequences."""

sequence: Sequence[T]
"""The sequence to view into."""

@classmethod
def create(cls, sequence: Sequence[U]) -> SequenceView[U]:
return cls(sequence) # type: ignore
"""The sequence to view."""

@overload
def __getitem__(self, index: int) -> T:
Expand All @@ -34,7 +29,7 @@ def __getitem__(self, index: slice) -> SequenceView[T]:

def __getitem__(self, index: Union[int, slice]) -> Union[T, SequenceView[T]]:
if is_slice(index):
return self.create(self.sequence[index])
return type(self)(self.sequence[index])

return self.sequence[index] # type: ignore

Expand Down
59 changes: 19 additions & 40 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "iters"
version = "0.15.0"
version = "0.16.0"
description = "Composable external iteration."
authors = ["nekitdev"]
license = "MIT"
Expand Down Expand Up @@ -31,74 +31,53 @@ include = "iters"
[tool.poetry.dependencies]
python = ">= 3.8"

typing-aliases = ">= 1.2.0"
typing-extensions = ">= 4.8.0"
typing-aliases = "^1.4.1"
typing-extensions = "^4.9.0"

named = ">= 1.3.0"
orderings = ">= 1.1.0"
named = "^1.3.0"
orderings = "^1.1.0"

solus = ">= 1.1.0"
solus = "^1.1.0"

async-extensions = ">= 1.4.1"
mixed-methods = ">= 1.0.2"

[tool.poetry.group.format]
optional = true
async-extensions = "^1.4.1"
mixed-methods = "^1.0.2"

[tool.poetry.group.format.dependencies]
black = "23.11.0"
flake8-pyproject = "1.2.3"

[tool.poetry.group.format.dependencies.flake8]
version = "6.1.0"
python = ">= 3.8.1"

[tool.poetry.group.format.dependencies.isort]
version = "5.12.0"

[tool.poetry.group.check]
optional = true
ruff = "0.1.11"

[tool.poetry.group.check.dependencies]
mypy = "1.7.1"

[tool.poetry.group.test]
optional = true
mypy = "1.8.0"

[tool.poetry.group.test.dependencies]
pytest = "7.4.3"
coverage = "7.4.0"
pytest = "7.4.4"
pytest-cov = "4.1.0"

[tool.poetry.group.docs]
optional = true

[tool.poetry.group.docs.dependencies]
mkdocs = "1.5.3"
mkdocs-material = "9.4.11"
mkdocs-material = "9.5.3"

[tool.poetry.group.docs.dependencies.mkdocstrings]
version = "0.24.0"
extras = ["python"]

[tool.poetry.group.dev]
[tool.poetry.group.release]
optional = true

[tool.poetry.group.dev.dependencies]
[tool.poetry.group.release.dependencies]
changelogging = "1.3.0"

[tool.black]
line_length = 100
[tool.ruff]
line-length = 100

[tool.flake8]
max_line_length = 100
[tool.ruff.lint]
ignore = [
"E402", # module level import not at top of file (circular import fixes)
]

[tool.isort]
line_length = 100
profile = "black"

[tool.pytest.ini_options]
addopts = "--cov iters"
testpaths = ["tests"]
Expand Down Expand Up @@ -127,7 +106,7 @@ strict = true

[tool.changelogging]
name = "iters"
version = "0.15.0"
version = "0.16.0"
url = "https://github.com/nekitdev/iters"
directory = "changes"
output = "CHANGELOG.md"
Expand Down

0 comments on commit 4658842

Please sign in to comment.