Przeglądaj źródła

fix(skills): finish uv-first sweep across python skills + version currency

Continuation of the python-env fix — the SKILL.md bodies were uv-first but
reference files and helper scripts still used pip. Sweep the remainder:

- pip install -> uv add / uv add --dev / uvx across typing, pytest, async,
  database reference files (~20 sites) and the check-types/run-tests scripts.
- CI snippets + type-checker/command examples now use setup-uv + uv run.
- python-typing-ops: add a "when to consider ty" note (Astral's preview
  Rust type checker) alongside mypy/pyright.
- Version currency: example floors -> 3.11, Python 3.13 note in python-env.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0xDarkMatter 1 tydzień temu
rodzic
commit
5b0132de8d

+ 2 - 2
skills/python-async-ops/references/performance.md

@@ -5,7 +5,7 @@ Performance patterns for high-throughput async applications.
 ## uvloop - Drop-in Event Loop Replacement
 
 ```python
-# Install: pip install uvloop
+# Install: uv add uvloop
 
 # Option 1: Install as default (before any asyncio calls)
 import uvloop
@@ -358,7 +358,7 @@ class AsyncProfiler:
 
 
 # Use yappi for comprehensive profiling
-# pip install yappi
+# uv add --dev yappi
 import yappi
 
 yappi.set_clock_type("wall")  # For async code

+ 3 - 3
skills/python-database-ops/references/migrations.md

@@ -5,11 +5,11 @@ Schema migration patterns for SQLAlchemy projects.
 ## Setup
 
 ```bash
-# Install
-pip install alembic
+# Install (project dependency)
+uv add alembic
 
 # Initialize in project root
-alembic init alembic
+uv run alembic init alembic
 
 # For async projects
 alembic init -t async alembic

+ 3 - 0
skills/python-env/SKILL.md

@@ -98,6 +98,9 @@ uv python list              # show available + installed
 uv init --python 3.12 app   # pin a project to a version
 ```
 
+3.13 is the current stable release (free-threading and JIT, both opt-in); 3.11+
+is a sensible floor for new projects (TaskGroup, `Self`, faster interpreter).
+
 ## Minimal pyproject.toml
 
 ```toml

+ 6 - 6
skills/python-env/references/pyproject-patterns.md

@@ -8,7 +8,7 @@ Comprehensive patterns for Python project configuration.
 [project]
 name = "my-project"
 version = "0.1.0"
-requires-python = ">=3.10"
+requires-python = ">=3.11"
 dependencies = [
     "httpx>=0.25",
     "pydantic>=2.0",
@@ -28,7 +28,7 @@ version = "0.1.0"
 description = "A short description of the project"
 readme = "README.md"
 license = "MIT"
-requires-python = ">=3.10"
+requires-python = ">=3.11"
 authors = [
     { name = "Your Name", email = "you@example.com" }
 ]
@@ -87,7 +87,7 @@ build-backend = "hatchling.build"
 [project]
 name = "my-cli"
 version = "0.1.0"
-requires-python = ">=3.10"
+requires-python = ">=3.11"
 dependencies = [
     "typer>=0.9",
     "rich>=13.0",
@@ -110,7 +110,7 @@ build-backend = "hatchling.build"
 [project]
 name = "my-api"
 version = "0.1.0"
-requires-python = ">=3.10"
+requires-python = ">=3.11"
 dependencies = [
     "fastapi>=0.100",
     "uvicorn[standard]>=0.23",
@@ -137,7 +137,7 @@ dev = [
 ```toml
 [tool.ruff]
 line-length = 100
-target-version = "py310"
+target-version = "py311"
 exclude = [
     ".git",
     ".venv",
@@ -211,7 +211,7 @@ filterwarnings = [
 
 ```toml
 [tool.mypy]
-python_version = "3.10"
+python_version = "3.11"
 strict = true
 warn_return_any = true
 warn_unused_ignores = true

+ 3 - 0
skills/python-pytest-ops/SKILL.md

@@ -159,6 +159,9 @@ def client(app):
 
 ## Quick Reference
 
+Run these inside the project env — prefix with `uv run` (e.g. `uv run pytest -v`).
+Bare `pytest` is shown below for brevity.
+
 | Command | Description |
 |---------|-------------|
 | `pytest` | Run all tests |

+ 1 - 1
skills/python-pytest-ops/references/async-testing.md

@@ -5,7 +5,7 @@ Testing asyncio code with pytest-asyncio.
 ## Setup
 
 ```bash
-pip install pytest-asyncio
+uv add --dev pytest-asyncio
 ```
 
 ```ini

+ 12 - 13
skills/python-pytest-ops/references/coverage-strategies.md

@@ -5,7 +5,7 @@ Comprehensive code coverage with pytest-cov.
 ## Setup
 
 ```bash
-pip install pytest-cov
+uv add --dev pytest-cov
 ```
 
 ## Basic Usage
@@ -121,15 +121,14 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v4
-      - uses: actions/setup-python@v5
-        with:
-          python-version: '3.11'
+      - name: Install uv
+        uses: astral-sh/setup-uv@v5
 
       - name: Install dependencies
-        run: pip install -e .[test]
+        run: uv sync
 
       - name: Run tests with coverage
-        run: pytest --cov=src --cov-report=xml
+        run: uv run pytest --cov=src --cov-report=xml
 
       - name: Upload coverage to Codecov
         uses: codecov/codecov-action@v4
@@ -173,24 +172,24 @@ coverage report
 
 ```bash
 # Show coverage for changed lines only (with diff-cover)
-pip install diff-cover
+uv add --dev diff-cover
 
-pytest --cov=src --cov-report=xml
-diff-cover coverage.xml --compare-branch=origin/main
+uv run pytest --cov=src --cov-report=xml
+uv run diff-cover coverage.xml --compare-branch=origin/main
 ```
 
 ## Mutation Testing
 
 ```bash
 # Beyond coverage: test quality with mutmut
-pip install mutmut
+uv add --dev mutmut
 
 # Run mutation testing
-mutmut run --paths-to-mutate=src/
+uv run mutmut run --paths-to-mutate=src/
 
 # View results
-mutmut results
-mutmut html
+uv run mutmut results
+uv run mutmut html
 ```
 
 ## Coverage Reports

+ 2 - 2
skills/python-pytest-ops/references/integration-testing.md

@@ -84,7 +84,7 @@ async def test_async_query(async_session):
 ## TestContainers
 
 ```python
-# pip install testcontainers
+# uv add --dev testcontainers
 
 import pytest
 from testcontainers.postgres import PostgresContainer
@@ -233,7 +233,7 @@ def test_user_creation_flow(client):
 ## Snapshot Testing
 
 ```python
-# pip install syrupy
+# uv add --dev syrupy
 
 import pytest
 from syrupy.assertion import SnapshotAssertion

+ 1 - 1
skills/python-pytest-ops/references/mocking-patterns.md

@@ -176,7 +176,7 @@ def test_with_autospec():
 ## pytest-mock Plugin
 
 ```python
-# pip install pytest-mock
+# uv add --dev pytest-mock
 
 def test_with_mocker(mocker):
     # mocker is a fixture that wraps unittest.mock

+ 3 - 3
skills/python-pytest-ops/references/test-architecture.md

@@ -324,7 +324,7 @@ def order(user):
 ## Performance Testing
 
 ```python
-# pip install pytest-benchmark
+# uv add --dev pytest-benchmark
 
 def test_sort_performance(benchmark):
     """Benchmark sorting algorithm."""
@@ -333,14 +333,14 @@ def test_sort_performance(benchmark):
     assert result == sorted(data)
 
 
-# pip install pytest-timeout
+# uv add --dev pytest-timeout
 @pytest.mark.timeout(5)  # Fail if takes >5 seconds
 def test_with_timeout():
     slow_operation()
 
 
 # Track memory
-# pip install pytest-memray
+# uv add --dev pytest-memray
 @pytest.mark.limit_memory("100 MB")
 def test_memory_usage():
     large_operation()

+ 3 - 3
skills/python-pytest-ops/scripts/run-tests.sh

@@ -54,15 +54,15 @@ done
 
 # Check if pytest is installed
 if ! command -v pytest &> /dev/null; then
-    echo -e "${RED}pytest not found. Install with: pip install pytest${NC}"
+    echo -e "${RED}pytest not found. Install with: uv add --dev pytest${NC}"
     exit 1
 fi
 
 # Watch mode
 if [[ -n "$WATCH" ]]; then
     if ! command -v ptw &> /dev/null; then
-        echo -e "${YELLOW}pytest-watch not found. Installing...${NC}"
-        pip install pytest-watch
+        echo -e "${YELLOW}pytest-watch not found. Install with: uv add --dev pytest-watch${NC}"
+        exit 1
     fi
     echo -e "${GREEN}Starting watch mode...${NC}"
     ptw -- $PYTEST_ARGS $COVERAGE

+ 8 - 3
skills/python-typing-ops/SKILL.md

@@ -190,11 +190,11 @@ API_VERSION: Final[str] = "v2"
 ## Type Checker Commands
 
 ```bash
-# mypy
-mypy src/ --strict
+# mypy (run inside the project env)
+uv run mypy src/ --strict
 
 # pyright
-pyright src/
+uv run pyright src/
 
 # In pyproject.toml
 [tool.mypy]
@@ -202,6 +202,11 @@ strict = true
 python_version = "3.11"
 ```
 
+**Emerging: `ty`** — Astral's Rust-based type checker (same toolchain as uv +
+ruff), dramatically faster than mypy. Still in preview (pre-1.0), so mypy or
+pyright remain the production default — but worth watching, and easy to try:
+`uvx ty check`. Adopt for new projects once it stabilizes.
+
 ## Additional Resources
 
 - `./references/generics-advanced.md` - TypeVar, ParamSpec, TypeVarTuple

+ 10 - 17
skills/python-typing-ops/references/mypy-config.md

@@ -211,28 +211,24 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v4
-      - uses: actions/setup-python@v5
-        with:
-          python-version: '3.11'
+      - name: Install uv
+        uses: astral-sh/setup-uv@v5
 
       - name: Install dependencies
-        run: |
-          pip install mypy
-          pip install -e .[dev]
+        run: uv sync
 
       - name: Run mypy
-        run: mypy src/
+        run: uv run mypy src/
 
   pyright:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v4
-      - uses: actions/setup-python@v5
-        with:
-          python-version: '3.11'
+      - name: Install uv
+        uses: astral-sh/setup-uv@v5
 
       - name: Install dependencies
-        run: pip install -e .[dev]
+        run: uv sync
 
       - name: Run pyright
         uses: jakebailey/pyright-action@v2
@@ -254,14 +250,11 @@ repos:
 ## Common Type Stubs
 
 ```bash
-# Install type stubs
-pip install types-requests
-pip install types-redis
-pip install types-PyYAML
-pip install boto3-stubs[essential]
+# Install type stubs (dev-only)
+uv add --dev types-requests types-redis types-PyYAML "boto3-stubs[essential]"
 
 # Or use mypy to find missing stubs
-mypy --install-types src/
+uv run mypy --install-types src/
 ```
 
 ## Gradual Typing Strategy

+ 2 - 2
skills/python-typing-ops/scripts/check-types.sh

@@ -52,7 +52,7 @@ run_mypy() {
     echo -e "${BLUE}=== Running mypy ===${NC}"
 
     if ! command -v mypy &> /dev/null; then
-        echo -e "${YELLOW}mypy not found. Install with: pip install mypy${NC}"
+        echo -e "${YELLOW}mypy not found. Install with: uv add --dev mypy${NC}"
         return 1
     fi
 
@@ -77,7 +77,7 @@ run_pyright() {
     echo -e "${BLUE}=== Running pyright ===${NC}"
 
     if ! command -v pyright &> /dev/null; then
-        echo -e "${YELLOW}pyright not found. Install with: pip install pyright${NC}"
+        echo -e "${YELLOW}pyright not found. Install with: uv add --dev pyright${NC}"
         return 1
     fi