Skip to content

Commit

Permalink
✨ Add more-itertools for extras require
Browse files Browse the repository at this point in the history
  • Loading branch information
karakoo committed Jun 30, 2024
1 parent f95f996 commit c73f9a7
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 21 deletions.
45 changes: 24 additions & 21 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,43 @@
setup,
)

packages = find_packages('src')
packages = find_packages("src")

here = os.path.abspath(os.path.dirname(__file__))

with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = '\n' + f.read()
with io.open(os.path.join(here, "README.md"), encoding="utf-8") as f:
long_description = "\n" + f.read()

# noinspection SpellCheckingInspection
setup(
name='arko-wrapper',
name="arko-wrapper",
description="给你的Python迭代器加上魔法",
version='0.2.8',
long_description=long_description,
long_description_content_type='text/markdown',
author='Arko',
author_email='[email protected]',
python_requires='>=3.7',
url='https://github.com/ArkoClub/ArkoWrapper',
long_description_content_type="text/markdown",
author="Arko",
author_email="[email protected]",
python_requires=">=3.7",
url="https://github.com/ArkoClub/ArkoWrapper",
packages=packages,
package_dir={"": "src"},
install_requires=['typing_extensions'],
install_requires=["typing_extensions"],
extras_require={
'test': ['pytest', 'pytest-rerunfailures'],
"test": ["pytest", "pytest-rerunfailures"],
"more": ["more-itertools"],
},
include_package_data=True,
license='MIT',
license="MIT",
classifiers=[
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: Implementation :: CPython',
]
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
],
)
30 changes: 30 additions & 0 deletions src/arkowrapper/_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
runtime_checkable,
)

try:
import more_itertools
except ImportError:
more_itertools = None

__all__ = ["ArkoWrapper"]

T = TypeVar("T")
Expand Down Expand Up @@ -875,3 +880,28 @@ def pairwise(self) -> Self:

def batched(self, n: int = 2) -> Self:
return self.__class__(itertools.batched(self._tee(), n))

if more_itertools:

def chunked(self, n: Optional[int] = None, strict: bool = False) -> Self:
return self.__class__(more_itertools.chunked(self._tee(), n, strict))

def chunked_even(self, n: int) -> Self:
return self.__class__(more_itertools.chunked_even(self._tee(), n))

# noinspection SpellCheckingInspection
def ichunked(self, n: Optional[int] = None) -> Self:
return self.__class__(more_itertools.ichunked(self._tee(), n)).map(
self.__class__
)

def distribute(self, n: int) -> Self:
return self.__class__(more_itertools.distribute(n, self._tee())).map(
self.__class__
)

def divide(self, n: int) -> Self:
return self.__class__(more_itertools.divide(n, self._tee()))

def flatten(self) -> Self:
return self.__class__(more_itertools.flatten(self._tee()))

0 comments on commit c73f9a7

Please sign in to comment.