From 740a944ed0adf4d571aeb13ab46ae3f8d8908e9b Mon Sep 17 00:00:00 2001 From: Jo <10510431+j178@users.noreply.github.com> Date: Fri, 29 Mar 2024 17:15:58 +0800 Subject: [PATCH] Cleanup duplicated functions in rye-devtools (#933) * Cleanup rye-devtools * Remove unused imports --- rye-devtools/src/rye_devtools/find_downloads.py | 17 +---------------- rye-devtools/tests/test_basic.py | 3 ++- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/rye-devtools/src/rye_devtools/find_downloads.py b/rye-devtools/src/rye_devtools/find_downloads.py index 302868ef51..b7cec2c170 100644 --- a/rye-devtools/src/rye_devtools/find_downloads.py +++ b/rye-devtools/src/rye_devtools/find_downloads.py @@ -7,7 +7,6 @@ import abc import asyncio -import itertools import os import re import sys @@ -18,21 +17,7 @@ import httpx from httpx import HTTPStatusError -from .common import PlatformTriple, Version, fetch - - -def log(*args, **kwargs): - print(*args, file=sys.stderr, **kwargs) - - -def batched(iterable, n): - "Batch data into tuples of length n. The last batch may be shorter." - # batched('ABCDEFG', 3) --> ABC DEF G - if n < 1: - raise ValueError("n must be at least one") - it = iter(iterable) - while batch := tuple(itertools.islice(it, n)): - yield batch +from .common import PlatformTriple, Version, batched, fetch, log class PythonImplementation(StrEnum): diff --git a/rye-devtools/tests/test_basic.py b/rye-devtools/tests/test_basic.py index 0edafdf5c2..f5862a917d 100644 --- a/rye-devtools/tests/test_basic.py +++ b/rye-devtools/tests/test_basic.py @@ -1,5 +1,6 @@ import pytest -from rye_devtools.find_downloads import CPythonFinder, PlatformTriple, batched +from rye_devtools.common import batched +from rye_devtools.find_downloads import CPythonFinder, PlatformTriple def test_batched():