Skip to content

Commit 1c362d9

Browse files
authored
Merge pull request #56 from amirongit/feature/hashed-implementation
Feature/hashed implementation
2 parents fbbea86 + 67fe248 commit 1c362d9

29 files changed

Lines changed: 952 additions & 387 deletions

.github/workflows/cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ jobs:
1919
- run: uv sync
2020
- run: uv run ruff check pyenumerable test
2121
- run: uv run pyright pyenumerable test
22-
- run: uv run pytest -v --cov=pyenumerable.implementations --cov-report term-missing --cov-report term:skip-covered
22+
- run: uv run pytest -v --cov=pyenumerable.implementations --cov-report term-missing
2323
- run: uv build
2424
- run: uv publish --trusted-publishing always

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ jobs:
4242
with:
4343
python-version: ${{ matrix.python-version }}
4444
- run: uv sync
45-
- run: uv run pytest -v --cov=pyenumerable.implementations --cov-report term-missing --cov-report term:skip-covered
45+
- run: uv run pytest -v --cov=pyenumerable.implementations --cov-report term-missing

documentation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Implementation of .NET's [IEnumerable](https://learn.microsoft.com/en-us/dotnet/
44

55
## Architecture & Design
66

7-
PyEnumerable follows a relatively simple architecture, mainly because there isn't any reason to do otherwise!
7+
PyEnumerable follows a relatively simple architecture, mainly because there isn't any reason to do otherwise!<br/>
88
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.
99

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

2424
#### `Enumerable`
2525

26-
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.
26+
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/>
2727
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.
2828

2929
#### `Associable`
@@ -242,8 +242,7 @@ assert one.group_join(
242242
two,
243243
lambda x: x,
244244
lambda point: point.y,
245-
lambda x,
246-
points: (x, points.source)
245+
lambda x, points: (x, points.source)
247246
).source == (
248247
(1, Point(1, 1), Point(2, 1)),
249248
(2, Point(3, 2), Point(4, 2), Point(5, 2))
@@ -707,7 +706,8 @@ type parameters:
707706

708707
#### `PurePythonEnumerable`
709708

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

712712
usage:
713713
```py

pyenumerable/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
__all__ = ["Enumerable", "PurePythonEnumerable", "pp_enumerable"]
1010
__author__ = "AmirHossein Ahmadi"
1111
__license__ = "WTFPL"
12-
__version__ = "1.1.5"
12+
__version__ = "2.0.0"
1313
__maintainer__ = "AmirHossein Ahmadi"
1414
__email__ = "amirthehossein@gmail.com"
1515
__documentation__ = "https://github.com/amirongit/PyEnumerable/blob/master/documentation.md"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from typing import Any
2+
3+
from pyenumerable.protocol._enumerable import Enumerable
4+
5+
6+
def assume_not_empty(instance: Enumerable[Any]) -> None:
7+
if instance.count_() == 0:
8+
msg = "Enumerable is empty"
9+
raise ValueError(msg)

0 commit comments

Comments
 (0)