Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ jobs:
- run: uv sync
- run: uv run ruff check pyenumerable test
- run: uv run pyright pyenumerable test
- run: uv run pytest -v --cov=pyenumerable.implementations --cov-report term-missing --cov-report term:skip-covered
- run: uv run pytest -v --cov=pyenumerable.implementations --cov-report term-missing
- run: uv build
- run: uv publish --trusted-publishing always
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- run: uv sync
- run: uv run pytest -v --cov=pyenumerable.implementations --cov-report term-missing --cov-report term:skip-covered
- run: uv run pytest -v --cov=pyenumerable.implementations --cov-report term-missing
10 changes: 5 additions & 5 deletions documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Implementation of .NET's [IEnumerable](https://learn.microsoft.com/en-us/dotnet/

## Architecture & Design

PyEnumerable follows a relatively simple architecture, mainly because there isn't any reason to do otherwise!
PyEnumerable follows a relatively simple architecture, mainly because there isn't any reason to do otherwise!<br/>
Extension methods defined by `IEnumerable` interface are grouped by their functionality under protocols located `pyenumerable.protocol` package; The main advantage provided by protocols over ABCs (abstract base classes) is the ability to define overloads w/ different signatures.

### Protocols
Expand All @@ -23,7 +23,7 @@ A callable which accepts two arguments of type `TSource` & returns a `bool` valu

#### `Enumerable`

This protocol consolidates all other protocols into a single one, allowing implementations to reference it instead of listing each individual protocol. This approach minimizes the risk of omitting any methods due to oversight.
This protocol consolidates all other protocols into a single one, allowing implementations to reference it instead of listing each individual protocol. This approach minimizes the risk of omitting any methods due to oversight.<br/>
It also enforces the presence of a property called `source` which can be used to access actual items inside an instance of a particular implementation.

#### `Associable`
Expand Down Expand Up @@ -242,8 +242,7 @@ assert one.group_join(
two,
lambda x: x,
lambda point: point.y,
lambda x,
points: (x, points.source)
lambda x, points: (x, points.source)
).source == (
(1, Point(1, 1), Point(2, 1)),
(2, Point(3, 2), Point(4, 2), Point(5, 2))
Expand Down Expand Up @@ -707,7 +706,8 @@ type parameters:

#### `PurePythonEnumerable`

A basic implementation of Enumerable; Written without the assumption of `TSource` conforming to `collections.abc.Hashable` or being immutable; preserves order.
Basic implementation of `pyenumerable.Enumerable`; Assumes that `TSource` conforms to `collections.abc.Hashable` & is immutable.<br/>
Violating this assumption may lead to unpredictable behaviour.

usage:
```py
Expand Down
2 changes: 1 addition & 1 deletion pyenumerable/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
__all__ = ["Enumerable", "PurePythonEnumerable", "pp_enumerable"]
__author__ = "AmirHossein Ahmadi"
__license__ = "WTFPL"
__version__ = "1.1.5"
__version__ = "2.0.0"
__maintainer__ = "AmirHossein Ahmadi"
__email__ = "amirthehossein@gmail.com"
__documentation__ = "https://github.com/amirongit/PyEnumerable/blob/master/documentation.md"
9 changes: 9 additions & 0 deletions pyenumerable/implementation_utility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import Any

from pyenumerable.protocol._enumerable import Enumerable


def assume_not_empty(instance: Enumerable[Any]) -> None:
if instance.count_() == 0:
msg = "Enumerable is empty"
raise ValueError(msg)
Loading