From 39c5fe810c392c2549a0c42da8d6286aa6efac68 Mon Sep 17 00:00:00 2001 From: Amethyst Reese Date: Mon, 5 Feb 2024 18:53:19 -0800 Subject: [PATCH] Modernize metadata and deps, support 3.8-3.12 (#154) * Modernize metadata and deps, support 3.8-3.12 * rtd config * rtd extras --- .flake8 | 2 ++ .github/workflows/build.yml | 5 ++-- .readthedocs.yml | 8 ++++-- aioitertools/builtins.py | 4 +-- aioitertools/helpers.py | 6 ++-- aioitertools/tests/builtins.py | 2 +- makefile | 27 ++++++++---------- mypy.ini | 2 -- pyproject.toml | 51 +++++++++++++++++++++------------- requirements-dev.txt | 10 ------- requirements.txt | 1 - 11 files changed, 57 insertions(+), 61 deletions(-) delete mode 100644 mypy.ini delete mode 100644 requirements-dev.txt delete mode 100644 requirements.txt diff --git a/.flake8 b/.flake8 index 8dad0a3..c7f1c97 100644 --- a/.flake8 +++ b/.flake8 @@ -8,6 +8,8 @@ ignore = E2 E3 E4 + E704 + max-line-length = 88 per-file-ignores = __init__.py: F401 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 897d77a..15ccf1d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11.0-rc.1 - 3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] os: [macOS-latest, ubuntu-latest, windows-latest] steps: @@ -26,8 +26,7 @@ jobs: - name: Install run: | python -m pip install --upgrade pip - make setup - pip install -U . + make EXTRAS=dev install - name: Test run: make test - name: Lint diff --git a/.readthedocs.yml b/.readthedocs.yml index 4456057..9d58d8c 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,9 +1,13 @@ version: 2 sphinx: configuration: docs/conf.py +build: + os: ubuntu-22.04 + tools: + python: "3.10" python: - version: 3.7 install: - - requirements: requirements-dev.txt - method: pip path: . + extra_requirements: + - docs diff --git a/aioitertools/builtins.py b/aioitertools/builtins.py index 947b674..bb98795 100644 --- a/aioitertools/builtins.py +++ b/aioitertools/builtins.py @@ -327,7 +327,7 @@ async def min(itr: AnyIterable[Orderable], **kwargs: Any) -> Any: return value -async def sum(itr: AnyIterable[T], start: T = None) -> T: +async def sum(itr: AnyIterable[T], start: Optional[T] = None) -> T: """ Compute the sum of a mixed iterable, adding each value with the start value. @@ -420,4 +420,4 @@ async def zip(*itrs: AnyIterable[Any]) -> AsyncIterator[Tuple[Any, ...]]: ) if builtins.any(isinstance(v, AnyStop) for v in values): break - yield values + yield tuple(values) diff --git a/aioitertools/helpers.py b/aioitertools/helpers.py index ded139e..bd7b794 100644 --- a/aioitertools/helpers.py +++ b/aioitertools/helpers.py @@ -14,11 +14,9 @@ else: # pragma: no cover class Orderable(Protocol): # pragma: no cover - def __lt__(self, other): - ... + def __lt__(self, other): ... - def __gt__(self, other): - ... + def __gt__(self, other): ... async def maybe_await(object: Union[Awaitable[T], T]) -> T: diff --git a/aioitertools/tests/builtins.py b/aioitertools/tests/builtins.py index eeeef1b..6accb15 100644 --- a/aioitertools/tests/builtins.py +++ b/aioitertools/tests/builtins.py @@ -364,5 +364,5 @@ class BuiltinsTest(TestCase): long = [0, 1, 2, 3, 5] result = await ait.list(ait.zip(short, long)) - expected = [["a", 0], ["b", 1], ["c", 2]] + expected = [("a", 0), ("b", 1), ("c", 2)] self.assertListEqual(expected, result) diff --git a/makefile b/makefile index 0ef049d..8a47935 100644 --- a/makefile +++ b/makefile @@ -1,35 +1,30 @@ -build: - flit build - -dev: - flit install --symlink - -setup: - python -m pip install -Ur requirements-dev.txt +PKG:=aioitertools +EXTRAS:=dev,docs .venv: python -m venv .venv - source .venv/bin/activate && make setup dev + source .venv/bin/activate && make install echo 'run `source .venv/bin/activate` to use virtualenv' venv: .venv +install: + python -m pip install -Ue .[$(EXTRAS)] + release: lint test clean flit publish format: - python -m usort format aioitertools - python -m black aioitertools + python -m ufmt format $(PKG) lint: - python -m flake8 aioitertools - python -m usort check aioitertools - python -m black --check aioitertools + python -m flake8 $(PKG) + python -m ufmt check $(PKG) test: - python -m coverage run -m aioitertools.tests + python -m coverage run -m $(PKG).tests python -m coverage report - python -m mypy aioitertools + python -m mypy -p $(PKG) html: .venv README.md docs/* source .venv/bin/activate && sphinx-build -b html docs html diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 976ba02..0000000 --- a/mypy.ini +++ /dev/null @@ -1,2 +0,0 @@ -[mypy] -ignore_missing_imports = True diff --git a/pyproject.toml b/pyproject.toml index aaa9121..476247e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,15 +1,13 @@ [build-system] -requires = ["flit_core >=2,<4"] +requires = ["flit_core >=3.8,<4"] build-backend = "flit_core.buildapi" -[tool.flit.metadata] -module = "aioitertools" -author = "Amethyst Reese" -author-email = "amy@noswap.com" -description-file = "README.md" -home-page = "https://aioitertools.omnilib.dev" -requires = ["typing_extensions>=4.0; python_version < '3.10'"] -requires-python = ">=3.6" +[project] +name = "aioitertools" +readme = "README.md" +authors = [{ name = "Amethyst Reese", email = "amethyst@n7.gg" }] +license = { file = "LICENSE" } +dynamic = ["version", "description"] classifiers = [ "Development Status :: 4 - Beta", "Framework :: AsyncIO", @@ -17,15 +15,31 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Topic :: Software Development :: Libraries", ] +requires-python = ">=3.8" +dependencies = ["typing_extensions>=4.0; python_version < '3.10'"] -[tool.flit.metadata.urls] -Documentation = "https://aioitertools.omnilib.dev/en/latest/" +[project.optional-dependencies] +dev = [ + "attribution==1.6.2", + "black==24.1.0", + "coverage==7.4.0", + "flake8==7.0.0", + "flit==3.9.0", + "mypy==1.8.0", + "usort==1.0.7", + "ufmt==2.3.0", +] +docs = [ + "sphinx==7.2.6", + "sphinx-mdinclude==0.5.3", +] + +[project.urls] +Documentation = "https://aioitertools.omnilib.dev" Github = "https://github.com/omnilib/aioitertools" [tool.flit.sdist] -exclude = [ - ".github/", -] +exclude = [".github/"] [tool.attribution] name = "aioitertools" @@ -44,9 +58,6 @@ precision = 1 show_missing = true skip_covered = true -[tool.isort] -line_length = 88 -multi_line_output = 3 -force_grid_wrap = false -include_trailing_comma = true -use_parentheses = true +[tool.mypy] +# strict = true +ignore_missing_imports = true \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index e549f0b..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,10 +0,0 @@ -attribution==1.5.2 -black==22.8.0 -coverage[toml]==6.2; python_version < "3.10" -coverage==6.4.4; python_version >= "3.10" -flake8==5.0.4 -flit==3.7.1 -mypy==0.971 -sphinx==4.3.2 -usort==1.0.5 -sphinx-mdinclude==0.5.2 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 3f9b940..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -typing_extensions>=4.0;python_version<"3.10"