Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move to uv #208

Merged
merged 5 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .github/dependabot.yml

This file was deleted.

1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9
14 changes: 4 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
FROM python:3.9
FROM ghcr.io/astral-sh/uv:python3.9-bookworm

# Set the working directory to /app
WORKDIR /app

ENV RYE_HOME="/opt/rye"
ENV PATH="$RYE_HOME/shims:$PATH"
RUN curl -sSf https://rye-up.com/get | RYE_INSTALL_OPTION="--yes" RYE_TOOLCHAIN="/usr/local/bin/python" bash
RUN rye config --set-bool behavior.use-uv=true
RUN rye config --set-bool behavior.global-python=true
RUN rye config --set default.dependency-operator="~="

COPY Makefile ./
COPY pyproject.toml ./
RUN make install
RUN make dev
RUN make types # Type-check to warm the cache

COPY . /app
RUN make quicksync
RUN make dev
RUN make validate_ci
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@ MAKEFLAGS = --no-print-directory

# Dependency management
install:
rye sync
uv sync

quicksync:
rye sync --no-lock
dev:
uv sync --all-extras

test:
@rye run pytest --cov=$(SRC_PATH) $(SRC_PATH) --cov-report xml:.coverage.xml --cov-report lcov:.coverage.lcov
@uv run pytest --cov=$(SRC_PATH) $(SRC_PATH) --cov-report xml:.coverage.xml --cov-report lcov:.coverage.lcov

test-with-coverage:
@echo "––– Testing –––"
@make test
@rye run diff-cover .coverage.xml
@uv run diff-cover .coverage.xml
@echo "✅✅✅ Tests passed ✅✅✅"

lint: ## Format code
@echo "––– Linting –––"
@rye run ruff format .
@rye run ruff . --fix --unsafe-fixes \
@uv run ruff format .
@uv run ruff . --fix --unsafe-fixes \
--extend-select F401 \
--extend-select F841
@echo "✅✅✅ Lint ✅✅✅"

types: ## Type-check code
@echo "––– Type-checking –––"
@rye run pyright .
@uv run pyright .
@echo "✅✅✅ Types ✅✅✅"

validate_ci: ## Run all checks
Expand All @@ -44,4 +44,4 @@ docker_ci: ## Run all checks in docker
@docker run iterpy make validate_ci

pr: ## Submit a PR
@rye run lm sync --squash --automerge
@uv run lm sync --squash --automerge
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ result = filter(is_even, map(multiply_by_2, [1,2,3]))
## Install

```bash
pip install iterpy
uv add iterpy
```

## Usage
Expand Down Expand Up @@ -90,7 +90,7 @@ Other Python projects have had similar ideas:

### Setup

1. We use [`rye`](https://rye.astral.sh/) for environment management. Once it is installed, set up your virtual environment using `rye sync`.
1. We use [`uv`](https://docs.astral.sh/uv/) for environment management. Once it is installed, setup the dev environment using `make dev`.

Or, use the devcontainer.

Expand Down
2 changes: 1 addition & 1 deletion iterpy/test_arr.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def test_flatten_str(self):

def test_flatten_includes_primitives(self):
test_input: list[str | list[int] | None] = ["first", [2], None]
result: Arr[int | str | None] = Arr(test_input).flatten()
result: Arr[int | str | None] = Arr(test_input).flatten() # type: ignore # TODO: Would love to see a fix for this
assert result.to_list() == ["first", 2, None]

def test_flatten_removes_empty_iterators(self):
Expand Down
2 changes: 1 addition & 1 deletion iterpy/test_iter.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def test_flatten_str(self):

def test_flatten_includes_primitives(self):
test_input: list[str | list[int] | None] = ["first", [2], None]
result: Iter[int | str | None] = Iter(test_input).flatten()
result: Iter[int | str | None] = Iter(test_input).flatten() # type: ignore # TODO: Would love to see a fix for this
assert result.to_list() == ["first", 2, None]

def test_flatten_removes_empty_iterators(self):
Expand Down
927 changes: 927 additions & 0 deletions uv.lock

Large diffs are not rendered by default.