Skip to content

Commit 700e512

Browse files
authored
Switch from Poetry to UV for dependency management (#781)
* Update docs to Material theme and 1.0 compatibility - Switch to Material for MkDocs theme with Redis branding - Combine connections.md and redis_modules.md into redis_setup.md - Recommend Redis 8 over Redis Stack - Update all code examples for 1.0: - Add model-level index=True to indexed models - Update Pydantic validators to v2 syntax - Update error message formats to Pydantic v2 style - Replace @app.on_event with lifespan pattern in FastAPI examples - Replace Migrator().run() with om migrate CLI reference * Link to hosted documentation site in README * Add RedisInsight to spellcheck wordlist * Switch from Poetry to UV for dependency management - Convert pyproject.toml to PEP 621 format with hatchling backend - Update Makefile to use uv commands - Update CI, PyPI publish, and docs workflows for UV - Update documentation references to UV - Add example apps (FastAPI, Flask) demonstrating all Redis OM features - Add tests for example app patterns - Add uv.lock, remove poetry.lock reference from pre-commit * Fix spellcheck and NaN injection vulnerability - Add 'uv' to spellcheck wordlist - Add safe_float() helper to reject NaN/Inf values in Flask app * Use controlled error payloads instead of raw exception strings
1 parent 979e74b commit 700e512

17 files changed

Lines changed: 4319 additions & 225 deletions

.github/wordlist.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,5 @@ issubclass
110110
ulid
111111
coroutine
112112
compat
113-
programmatically
113+
programmatically
114+
uv

.github/workflows/ci.yml

Lines changed: 9 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -27,44 +27,16 @@ jobs:
2727
steps:
2828
- name: Checkout
2929
uses: actions/checkout@v6
30+
- name: Install uv
31+
uses: astral-sh/setup-uv@v5
3032
- name: Setup Python 3.10
3133
uses: actions/setup-python@v6
3234
with:
3335
python-version: ${{env.pythonversion}}
34-
#----------------------------------------------
35-
# ----- install & configure poetry -----
36-
#----------------------------------------------
37-
- name: Install Poetry
38-
uses: snok/install-poetry@v1
39-
with:
40-
virtualenvs-create: true
41-
virtualenvs-in-project: true
42-
installer-parallel: true
43-
#----------------------------------------------
44-
# load cached venv if cache exists
45-
#----------------------------------------------
46-
- name: Load cached venv
47-
id: cached-poetry-dependencies
48-
uses: actions/cache@v5
49-
with:
50-
path: .venv
51-
key: venv-${{ runner.os }}-${{ env.pythonversion }}-${{ hashFiles('**/poetry.lock') }}
36+
- name: Install dependencies
37+
run: uv sync
5238
- name: Make sync version of library (redis_om)
5339
run: make sync
54-
#----------------------------------------------
55-
# install dependencies if cache does not exist
56-
#----------------------------------------------
57-
- name: Install dependencies
58-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
59-
run: poetry install --no-interaction --no-root
60-
#----------------------------------------------
61-
# install your root project, if required
62-
#----------------------------------------------
63-
- name: Install library
64-
run: poetry install --no-interaction
65-
#----------------------------------------------
66-
# run test suite
67-
#----------------------------------------------
6840
- name: Run linter
6941
run: |
7042
make dist
@@ -99,50 +71,22 @@ jobs:
9971
steps:
10072
- name: Checkout
10173
uses: actions/checkout@v6
74+
- name: Install uv
75+
uses: astral-sh/setup-uv@v5
10276
- name: Setup Python ${{ matrix.pyver }}
10377
uses: actions/setup-python@v6
10478
with:
10579
python-version: ${{ matrix.pyver }}
106-
#----------------------------------------------
107-
# ----- install & configure poetry -----
108-
#----------------------------------------------
109-
- name: Install Poetry
110-
uses: snok/install-poetry@v1
111-
with:
112-
virtualenvs-create: true
113-
virtualenvs-in-project: true
114-
installer-parallel: true
115-
#----------------------------------------------
116-
# load cached venv if cache exists
117-
#----------------------------------------------
118-
- name: Load cached venv
119-
id: cached-poetry-dependencies
120-
uses: actions/cache@v5
121-
with:
122-
path: .venv
123-
key: venv-${{ runner.os }}-${{ matrix.pyver }}-${{ hashFiles('**/poetry.lock') }}
124-
#----------------------------------------------
125-
# Make sync version of library (redis_om)
126-
#----------------------------------------------
80+
- name: Install dependencies
81+
run: uv sync
12782
- name: Make sync version of library (redis_om)
12883
run: make sync
129-
#----------------------------------------------
130-
# install dependencies if cache does not exist
131-
#----------------------------------------------
132-
- name: Install dependencies
133-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
134-
run: poetry install --no-interaction --no-root
135-
#----------------------------------------------
136-
# install your root project, if required
137-
#----------------------------------------------
138-
- name: Install library
139-
run: poetry install --no-interaction
14084
- name: Run unittests (redisstack:${{ matrix.redisstack }}, ${{ matrix.os }})
14185
env:
14286
REDIS_OM_URL: "redis://localhost:6379?decode_responses=True"
14387
run: |
14488
make test
145-
poetry run coverage xml
89+
uv run coverage xml
14690
- name: Upload coverage
14791
uses: codecov/codecov-action@v5
14892
with:

.github/workflows/docs-pages.yml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,19 @@ jobs:
2222
- name: Checkout
2323
uses: actions/checkout@v6
2424

25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v5
27+
2528
- name: Set up Python
2629
uses: actions/setup-python@v6
2730
with:
2831
python-version: "3.11"
2932

30-
- name: Install Poetry
31-
uses: snok/install-poetry@v1
32-
with:
33-
virtualenvs-create: true
34-
virtualenvs-in-project: true
35-
installer-parallel: true
36-
37-
- name: Load cached venv
38-
id: cached-poetry-dependencies
39-
uses: actions/cache@v5
40-
with:
41-
path: .venv
42-
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
43-
4433
- name: Install dependencies
45-
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
46-
run: poetry install --no-interaction --no-root
47-
48-
- name: Install library
49-
run: poetry install --no-interaction
34+
run: uv sync
5035

5136
- name: Build MkDocs site
52-
run: poetry run mkdocs build
37+
run: uv run mkdocs build
5338

5439
- name: Setup Pages
5540
uses: actions/configure-pages@v5

.github/workflows/pypi-publish.yaml

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,45 @@ on:
44
types: [ published ]
55

66
jobs:
7-
pytest:
7+
publish:
88
name: Publish to PyPi
99
runs-on: ubuntu-latest
10-
env:
11-
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
10+
environment: release
11+
permissions:
12+
id-token: write
1213
steps:
13-
- uses: actions/checkout@master
14+
- uses: actions/checkout@v6
1415

15-
- name: get version from tag
16+
- name: Get version from tag
1617
id: get_version
1718
run: |
1819
realversion="${GITHUB_REF/refs\/tags\//}"
1920
realversion="${realversion//v/}"
20-
echo "::set-output name=VERSION::$realversion"
21+
echo "VERSION=$realversion" >> $GITHUB_OUTPUT
2122
2223
- name: Set the version for publishing
2324
uses: sandstromviktor/toml-editor@2.0.0
2425
with:
2526
file: "pyproject.toml"
26-
key: "tool.poetry.version"
27+
key: "project.version"
2728
value: "${{ steps.get_version.outputs.VERSION }}"
2829

29-
- name: Set up Python 3.9
30+
- name: Install uv
31+
uses: astral-sh/setup-uv@v5
32+
33+
- name: Set up Python
3034
uses: actions/setup-python@v6
3135
with:
32-
python-version: 3.9
36+
python-version: "3.11"
3337

34-
- name: Cache Poetry virtualenv
35-
uses: actions/cache@v5
36-
id: cache
37-
with:
38-
path: ~/.virtualenvs
39-
key: poetry-${{ hashFiles('**/poetry.lock') }}
40-
restore-keys: |
41-
poetry-${{ hashFiles('**/poetry.lock') }}
42-
43-
- name: Set Poetry config
44-
run: |
45-
pip install --upgrade pip poetry==1.8.4
46-
poetry config virtualenvs.in-project false
47-
poetry config virtualenvs.path ~/.virtualenvs
48-
poetry export --dev --without-hashes -o requirements.txt
49-
pip install -r requirements.txt
38+
- name: Install dependencies
39+
run: uv sync
5040

5141
- name: Make sync version of library (redis_om)
5242
run: make sync
5343

54-
- name: Install
55-
run: poetry install --no-interaction
44+
- name: Build package
45+
run: uv build
5646

5747
- name: Publish to PyPI
58-
run: |
59-
poetry publish -u __token__ -p ${{ secrets.PYPI_TOKEN }} --build
48+
uses: pypa/gh-action-pypi-publish@release/v1

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ repos:
44
hooks:
55
- id: codespell
66
args: [--write-changes]
7-
exclude: ^(poetry\.lock|\.git/|docs/.*\.md)$
7+
exclude: ^(uv\.lock|\.git/|docs/.*\.md)$

AGENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ Redis OM Python is an object mapping library for Redis that provides high-level
1010

1111
### Setup and Installation
1212
```bash
13-
# Install dependencies using Poetry (preferred)
14-
poetry install
13+
# Install dependencies using uv (preferred)
14+
uv sync
1515

1616
# Or directly with pip
1717
pip install -e .
@@ -177,7 +177,7 @@ class Address(EmbeddedJsonModel):
177177

178178
- **docs/**: Comprehensive documentation in Markdown
179179
- **docker-compose.yml**: Redis Stack and OSS Redis instances for testing
180-
- **pyproject.toml**: Poetry configuration with CLI script definitions
180+
- **pyproject.toml**: Project configuration with CLI script definitions
181181
- **.github/**: CI/CD workflows and issue templates
182182
- **Session.vim**: Vim session configuration for development
183183

CONTRIBUTING.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ Redis OM Python is an object mapping library for Redis that provides declarative
2525

2626
### Prerequisites
2727

28-
- Python 3.8 or higher (we test on 3.8-3.13)
29-
- [Poetry](https://python-poetry.org/docs/#installation) for dependency management
28+
- Python 3.10 or higher (we test on 3.10-3.13)
29+
- [uv](https://docs.astral.sh/uv/) for dependency management
3030
- Docker and Docker Compose for running Redis
3131
- Make (for running development commands)
3232

@@ -45,7 +45,7 @@ Redis OM Python is an object mapping library for Redis that provides declarative
4545
make install
4646
```
4747

48-
This will use Poetry to install all dependencies in a virtual environment.
48+
This will use uv to install all dependencies in a virtual environment.
4949

5050
3. **Start Redis containers:**
5151

@@ -57,12 +57,6 @@ Redis OM Python is an object mapping library for Redis that provides declarative
5757
- Redis Stack (port 6380) - includes RediSearch and RedisJSON modules
5858
- Redis OSS (port 6381) - standard Redis for compatibility testing
5959

60-
4. **Enter the Poetry shell (optional):**
61-
62-
```bash
63-
make shell
64-
```
65-
6660
## Project Architecture
6761

6862
### � Critical: Dual Async/Sync Architecture
@@ -145,7 +139,7 @@ make sync
145139
vim tests/test_your_feature.py
146140

147141
# 5. Run tests iteratively
148-
poetry run pytest tests/test_your_feature.py -vv
142+
uv run pytest tests/test_your_feature.py -vv
149143

150144
# 6. Format and lint
151145
make format
@@ -164,16 +158,16 @@ make test
164158
make test
165159

166160
# Run specific test file
167-
poetry run pytest tests/test_hash_model.py -vv
161+
uv run pytest tests/test_hash_model.py -vv
168162

169163
# Run specific test
170-
poetry run pytest tests/test_hash_model.py::test_saves_model -vv
164+
uv run pytest tests/test_hash_model.py::test_saves_model -vv
171165

172166
# Run with coverage
173-
poetry run pytest --cov=aredis_om --cov=redis_om --cov-report=term-missing
167+
uv run pytest --cov=aredis_om --cov=redis_om --cov-report=term-missing
174168

175169
# Run tests in parallel
176-
poetry run pytest -n auto
170+
uv run pytest -n auto
177171

178172
# Test against OSS Redis (without modules)
179173
make test_oss

0 commit comments

Comments
 (0)