From 0279a653e691eed5422042bc7153afbe7a8e40b0 Mon Sep 17 00:00:00 2001 From: Martin Bernstorff Date: Thu, 4 Jan 2024 11:21:53 +0000 Subject: [PATCH] major: rename to iterpy to align with pypi --- .cookiecutter.json | 8 +++--- .cruft.json | 8 +++--- CONTRIBUTING.md | 6 ++--- README.md | 26 +++++++++---------- {iter => iterpy}/__init__.py | 0 {iter => iterpy}/_generate_pyi.py | 4 +-- {iter => iterpy}/_iter.py | 4 +-- {iter => iterpy}/_iter.pyi | 12 ++++----- .../benchmark/query_1/input_data.py | 0 .../benchmark/query_1/iterators_q1.py | 8 +++--- .../benchmark/query_1/polars_q1.py | 0 {iter => iterpy}/benchmark/utils.py | 0 {iter => iterpy}/py.typed | 0 {iter => iterpy}/test_iter.py | 2 +- pyproject.toml | 10 +++---- 15 files changed, 44 insertions(+), 44 deletions(-) rename {iter => iterpy}/__init__.py (100%) rename {iter => iterpy}/_generate_pyi.py (94%) rename {iter => iterpy}/_iter.py (97%) rename {iter => iterpy}/_iter.pyi (90%) rename {iter => iterpy}/benchmark/query_1/input_data.py (100%) rename {iter => iterpy}/benchmark/query_1/iterators_q1.py (93%) rename {iter => iterpy}/benchmark/query_1/polars_q1.py (100%) rename {iter => iterpy}/benchmark/utils.py (100%) rename {iter => iterpy}/py.typed (100%) rename {iter => iterpy}/test_iter.py (99%) diff --git a/.cookiecutter.json b/.cookiecutter.json index 1509169..b8c7592 100644 --- a/.cookiecutter.json +++ b/.cookiecutter.json @@ -6,12 +6,12 @@ "author": "Martin Bernstorff", "copyright_year": "2023", "email": "martinbernstorff@gmail.com", - "friendly_name": "Iter", - "github_repo": "Iter", + "friendly_name": "iterpy", + "github_repo": "iterpy", "github_user": "MartinBernstorff", "license": "MIT", - "package_name": "Iter", - "project_name": "Iter", + "package_name": "iterpy", + "project_name": "iterpy", "release_to_pypi": "yes", "version": "0.0.0" } \ No newline at end of file diff --git a/.cruft.json b/.cruft.json index caa1d4a..520fc6a 100644 --- a/.cruft.json +++ b/.cruft.json @@ -4,13 +4,13 @@ "checkout": null, "context": { "cookiecutter": { - "project_name": "Iter", - "package_name": "Iter", - "friendly_name": "Iter", + "project_name": "iterpy", + "package_name": "iterpy", + "friendly_name": "iterpy", "author": "Martin Bernstorff", "email": "martinbernstorff@gmail.com", "github_user": "MartinBernstorff", - "github_repo": "Iter", + "github_repo": "iterpy", "version": "0.0.0", "copyright_year": "2023", "release_to_pypi": "no", diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5b13620..7d2a9eb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,9 +12,9 @@ Here is a list of important resources for contributors: - [Code of Conduct] [mit license]: https://opensource.org/licenses/MIT -[source code]: https://github.com/MartinBernstorff/Iter +[source code]: https://github.com/MartinBernstorff/iterpy [documentation]: https://iter.readthedocs.io/ -[issue tracker]: https://github.com/MartinBernstorff/Iter/issues +[issue tracker]: https://github.com/MartinBernstorff/iterpy/issues ## How to report a bug @@ -77,7 +77,7 @@ $ nox --session=pre-commit -- install It is recommended to open an issue before starting work on anything. This will allow a chance to talk it over with the owners and validate your approach. -[pull request]: https://github.com/MartinBernstorff/Iter/pulls +[pull request]: https://github.com/MartinBernstorff/iterpy/pulls diff --git a/README.md b/README.md index b9ae47e..0e82a94 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,23 @@ -# Iter +# iterpy [![Open in Dev Container](https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)][dev container] [![PyPI](https://img.shields.io/pypi/v/iter.svg)][pypi status] -[![Python Version](https://img.shields.io/pypi/pyversions/Iter)][pypi status] -[![Tests](https://github.com/MartinBernstorff/Iter/actions/workflows/tests.yml/badge.svg)][tests] +[![Python Version](https://img.shields.io/pypi/pyversions/iterpy)][pypi status] +[![Tests](https://github.com/MartinBernstorff/iterpy/actions/workflows/tests.yml/badge.svg)][tests] -[pypi status]: https://pypi.org/project/Iter/ -[tests]: https://github.com/MartinBernstorff/Iter/actions?workflow=Tests -[dev container]: https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/MartinBernstorff/Iter/ +[pypi status]: https://pypi.org/project/iterpy/ +[tests]: https://github.com/MartinBernstorff/iterpy/actions?workflow=Tests +[dev container]: https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/MartinBernstorff/iterpy/ **ALPHA**: APIs can change dramatically without notice. -Python has implemented `map`, `filter` etc. as functions, rather than methods on a sequence. This makes the result harder to read and Iterators less used than they could be. Iter exists to change that. +Python has implemented `map`, `filter` etc. as functions, rather than methods on a sequence. This makes the result harder to read and iterators less used than they could be. iterpy exists to change that. You get this 🔥: ```python -result = (Iter([1,2,3]) +result = (iterpy([1,2,3]) .map(multiply_by_2) .filter(is_even)) ``` @@ -44,7 +44,7 @@ pip install iterpy ## Usage ```python -from iter import Seq +from iterpy import Iter result = (Iter([1, 2]) .filter(lambda x: x % 2 == 0) @@ -55,7 +55,7 @@ assert result == [4] ``` ## Prior art -Iter stands on the shoulders of Scala, Rust etc. +iterpy stands on the shoulders of Scala, Rust etc. Other Python projects have had similar ideas: * [PyFunctional](https://github.com/EntilZha/PyFunctional) has existed for 7+ years with a comprehensive feature set. It is performant, with built-in lineage and caching. Unfortunately, this makes typing [non-trivial, with a 4+ year ongoing effort to add types](https://github.com/EntilZha/PyFunctional/issues/118). @@ -83,7 +83,7 @@ In cases where this conflicts with typical python implementations, the API shoul #### Devcontainer 1. Install [Orbstack](https://orbstack.dev/) or Docker Desktop. Make sure to complete the full install process before continuing. 2. If not installed, install VSCode -3. Press this [link](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/MartinBernstorff/Iter/) +3. Press this [link](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/MartinBernstorff/iterpy/) 4. Complete the setup process 5. Done! Easy as that. @@ -96,7 +96,7 @@ In cases where this conflicts with typical python implementations, the API shoul | 👩‍💻 **Usage Questions** | [GitHub Discussions] | | 🗯 **General Discussion** | [GitHub Discussions] | -[github issue tracker]: https://github.com/MartinBernstorff/Iter/issues -[github discussions]: https://github.com/MartinBernstorff/Iter/discussions +[github issue tracker]: https://github.com/MartinBernstorff/iterpy/issues +[github discussions]: https://github.com/MartinBernstorff/iterpy/discussions diff --git a/iter/__init__.py b/iterpy/__init__.py similarity index 100% rename from iter/__init__.py rename to iterpy/__init__.py diff --git a/iter/_generate_pyi.py b/iterpy/_generate_pyi.py similarity index 94% rename from iter/_generate_pyi.py rename to iterpy/_generate_pyi.py index 4636f54..0f0d63a 100644 --- a/iter/_generate_pyi.py +++ b/iterpy/_generate_pyi.py @@ -21,8 +21,8 @@ def flatten(self: Seq[TYPE[S] | T]) -> Seq[S]: ...""" combined_interface = f" # Code for generating the following is in {Path(__file__).name}" for mark in [ - TypeMarker("Iterable[S]"), - TypeMarker("Iterator[S]"), + TypeMarker("iterpyable[S]"), + TypeMarker("iterpyator[S]"), TypeMarker("tuple[S, ...]"), TypeMarker("Sequence[S]"), TypeMarker("list[S]"), diff --git a/iter/_iter.py b/iterpy/_iter.py similarity index 97% rename from iter/_iter.py rename to iterpy/_iter.py index 1801a9d..316bc57 100644 --- a/iter/_iter.py +++ b/iterpy/_iter.py @@ -27,7 +27,7 @@ def __getitem__(self, index: int | slice) -> T | "Iter[T]": if isinstance(index, int) and index >= 0: try: return list(self._non_consumable)[index] - except StopIteration: + except Stopiterpyation: raise IndexError("Index out of range") from None elif isinstance(index, slice): return Iter( @@ -54,7 +54,7 @@ def to_list(self) -> list[T]: def to_tuple(self) -> tuple[T, ...]: return tuple(self._iterator) # pragma: no cover - def to_iter(self) -> Iterator[T]: + def to_iterator(self) -> Iterator[T]: return iter(self._iterator) # pragma: no cover def to_set(self) -> set[T]: diff --git a/iter/_iter.pyi b/iterpy/_iter.pyi similarity index 90% rename from iter/_iter.pyi rename to iterpy/_iter.pyi index e566e29..9fc9068 100644 --- a/iter/_iter.pyi +++ b/iterpy/_iter.pyi @@ -4,18 +4,18 @@ This type stub file was generated by pyright. from collections.abc import ( Callable, - Iterable, - Iterator, + iterpyable, + iterpyator, Sequence, ) -from typing import Generic, TypeVar, overload +from typing import Generic, Iterable, Iterator, TypeVar, overload S = TypeVar("S") T = TypeVar("T") U = TypeVar("U") -Iterables: TypeVar = ( - Iterable | Iterator | tuple | list | set | frozenset # type: ignore +iterpyables: TypeVar = ( + iterpyable | iterpyator | tuple | list | set | frozenset # type: ignore ) class Iter(Generic[T]): @@ -27,7 +27,7 @@ class Iter(Generic[T]): def count(self) -> int: ... def to_list(self) -> list[T]: ... def to_tuple(self) -> tuple[T, ...]: ... - def to_iter(self) -> Iterator[T]: ... + def to_iterator(self) -> Iterator[T]: ... def to_set(self) -> set[T]: ... def map(self, func: Callable[[T], S]) -> Iter[S]: # noqa: A003 ... diff --git a/iter/benchmark/query_1/input_data.py b/iterpy/benchmark/query_1/input_data.py similarity index 100% rename from iter/benchmark/query_1/input_data.py rename to iterpy/benchmark/query_1/input_data.py diff --git a/iter/benchmark/query_1/iterators_q1.py b/iterpy/benchmark/query_1/iterators_q1.py similarity index 93% rename from iter/benchmark/query_1/iterators_q1.py rename to iterpy/benchmark/query_1/iterators_q1.py index 81b9f2d..be4cd0c 100644 --- a/iter/benchmark/query_1/iterators_q1.py +++ b/iterpy/benchmark/query_1/iterators_q1.py @@ -5,9 +5,9 @@ from enum import Enum from typing import Any -from iter import Iter -from iter.benchmark.query_1.input_data import Q1_DATA -from iter.benchmark.utils import benchmark_method +from iterpy import Iter +from iterpy.benchmark.query_1.input_data import Q1_DATA +from iterpy.benchmark.utils import benchmark_method class LineStatus(Enum): @@ -105,7 +105,7 @@ def main_iterator(data: Sequence[Item]) -> Sequence[CategorySummary]: summaries = [ summarise_category(group, rows=values) - for group, values in mapping.to_iter() + for group, values in mapping.to_iterator() ] return summaries diff --git a/iter/benchmark/query_1/polars_q1.py b/iterpy/benchmark/query_1/polars_q1.py similarity index 100% rename from iter/benchmark/query_1/polars_q1.py rename to iterpy/benchmark/query_1/polars_q1.py diff --git a/iter/benchmark/utils.py b/iterpy/benchmark/utils.py similarity index 100% rename from iter/benchmark/utils.py rename to iterpy/benchmark/utils.py diff --git a/iter/py.typed b/iterpy/py.typed similarity index 100% rename from iter/py.typed rename to iterpy/py.typed diff --git a/iter/test_iter.py b/iterpy/test_iter.py similarity index 99% rename from iter/test_iter.py rename to iterpy/test_iter.py index dcc8ac0..0fae4a7 100644 --- a/iter/test_iter.py +++ b/iterpy/test_iter.py @@ -1,6 +1,6 @@ from collections.abc import Sequence -from iter._iter import Iter +from iterpy._iter import Iter def test_chaining(): diff --git a/pyproject.toml b/pyproject.toml index ed4ceae..d9bbf84 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,10 +6,10 @@ build-backend = "setuptools.build_meta" "*" = ["py.typed", "*.pyi"] [project] -name = "iter" +name = "iterpy" version = "0.19.0" authors = [{ name = "Martin Bernstorff", email = "martinbernstorff@gmail.com" }] -description = "iter" +description = "iterpy" classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11" @@ -40,9 +40,9 @@ file = "README.md" content-type = "text/markdown" [project.urls] -homepage = "https://github.com/MartinBernstorff/Iter" -repository = "https://github.com/MartinBernstorff/Iter" -documentation = "https://MartinBernstorff.github.io/Iter/" +homepage = "https://github.com/MartinBernstorff/iterpy" +repository = "https://github.com/MartinBernstorff/iterpy" +documentation = "https://MartinBernstorff.github.io/iterpy/" [tool.pyright] exclude = [".*venv*"]