Coverage for typed_stream/__init__.py: 100%
8 statements
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-17 19:15 +0000
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-17 19:15 +0000
1# Licensed under the EUPL-1.2 or later.
2# You may obtain a copy of the licence in all the official languages of the
3# European Union at https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
5"""Typed Stream classes for easier handling of iterables.
7Examples:
8>>> import typed_stream
9>>> # Get sum of 10 squares
10>>> typed_stream.Stream.range(stop=10).map(lambda x: x * x).sum()
11285
12>>> # same as above
13>>> sum(typed_stream.Stream.counting().limit(10).map(pow, 2))
14285
15>>> # sum first 100 odd numbers
16>>> typed_stream.Stream.counting(start=1, step=2).limit(100).sum()
1710000
18>>> (typed_stream.Stream.counting()
19... .filter(typed_stream.functions.is_odd).limit(100).sum())
2010000
21>>> (typed_stream.Stream.counting()
22... .exclude(typed_stream.functions.is_even).limit(100).sum())
2310000
24>>> import typed_stream.functions
25>>> # Get the longest package name from requirements-dev.txt
26>>> (typed_stream.FileStream("requirements-dev.txt")
27... .filter()
28... .exclude(typed_stream.functions.method_partial(str.startswith, "#"))
29... .exclude(typed_stream.functions.method_partial(str.__contains__, "git+"))
30... .map(str.split, "==")
31... .starmap(lambda name, version = None: name)
32... .max(key=len))
33'flake8-no-implicit-concat'
34"""
36# isort:skip_file
38from . import _impl, exceptions, streamable, version
39from . import functions # noqa: F401
40from ._impl.file_streams import * # noqa: F401, F403s
41from ._impl.stream import * # noqa: F401, F403
42from .exceptions import * # noqa: F401, F403
43from .streamable import * # noqa: F401, F403
45__all__ = (*_impl.__all__, *streamable.__all__, *exceptions.__all__)
46__version__ = version.VERSION