ruff/crates/ty_python_semantic/resources/mdtest/external
David Peter 0bac023cd2
[ty] Lockfiles for mdtests with external dependencies (#22077)
## Summary

Add lockfiles for all mdtests which make use of external dependencies.
When running tests normally, we use this lockfile when creating the
temporary venv using `uv sync --locked`. A new
`MDTEST_UPGRADE_LOCKFILES` environment variable is used to switch to a
mode in which those lockfiles can be updated or regenerated. When using
the Python mdtest runner, this environment variable is automatically set
(because we use this command while developing, not to simulate exactly
what happens in CI). A command-line flag is provided to opt out of this.

## Test Plan

### Using the mdtest runner

#### Adding a new test (no lockfile yet)

* Removed `attrs.lock` to simulate this
* Ran `uv run crates/ty_python_semantic/mdtest.py -e external/`. The
lockfile is generated and the test succeeds.

#### Upgrading/downgrading a dependency

* Changed pydantic requirement from `pydantic==2.12.2` to
`pydantic==2.12.5` (also tested with `2.12.0`)
* Ran `uv run crates/ty_python_semantic/mdtest.py -e external/`. The
lockfile is updated and the test succeeds.

### Using cargo

#### Adding a new test (no lockfile yet)

* Removed `attrs.lock` to simulate this
* Ran `MDTEST_EXTERNAL=1 cargo test -p ty_python_semantic --test mdtest
mdtest__external` "naively", which outputs:
> Failed to setup in-memory virtual environment with dependencies:
Lockfile not found at
'/home/shark/ruff/crates/ty_python_semantic/resources/mdtest/external/attrs.lock'.
Run with `MDTEST_UPGRADE_LOCKFILES=1` to generate it.
* Ran `MDTEST_UPGRADE_LOCKFILES=1 MDTEST_EXTERNAL=1 cargo test -p
ty_python_semantic --test mdtest mdtest__external`. The lockfile is
updated and the test succeeds.

#### Upgrading/downgrading a dependency

* Changed pydantic requirement from `pydantic==2.12.2` to
`pydantic==2.12.5` (also tested with `2.12.0`)
* Ran `MDTEST_EXTERNAL=1 cargo test -p ty_python_semantic --test mdtest
mdtest__external` "naively", which outputs a similar error message as
above.
* Ran the command suggested in the error message (`MDTEST_EXTERNAL=1
MDTEST_UPGRADE_LOCKFILES=1 cargo test -p ty_python_semantic --test
mdtest mdtest__external`). The lockfile is updated and the test
succeeds.
2025-12-19 14:29:52 +01:00
..
README.md [ty] mdtests with external dependencies (#20904) 2025-12-08 11:44:20 +01:00
attrs.lock [ty] Lockfiles for mdtests with external dependencies (#22077) 2025-12-19 14:29:52 +01:00
attrs.md [ty] mdtests with external dependencies (#20904) 2025-12-08 11:44:20 +01:00
numpy.lock [ty] Lockfiles for mdtests with external dependencies (#22077) 2025-12-19 14:29:52 +01:00
numpy.md [ty] mdtests with external dependencies (#20904) 2025-12-08 11:44:20 +01:00
pydantic.lock [ty] Lockfiles for mdtests with external dependencies (#22077) 2025-12-19 14:29:52 +01:00
pydantic.md [ty] Improve rendering of default values for function args (#22010) 2025-12-16 13:39:19 -05:00
pytest.lock [ty] Lockfiles for mdtests with external dependencies (#22077) 2025-12-19 14:29:52 +01:00
pytest.md [ty] mdtests with external dependencies (#20904) 2025-12-08 11:44:20 +01:00
sqlalchemy.lock [ty] Lockfiles for mdtests with external dependencies (#22077) 2025-12-19 14:29:52 +01:00
sqlalchemy.md [ty] Infer type variables within generic unions (#21862) 2025-12-09 16:22:59 +01:00
sqlmodel.lock [ty] Lockfiles for mdtests with external dependencies (#22077) 2025-12-19 14:29:52 +01:00
sqlmodel.md [ty] Lockfiles for mdtests with external dependencies (#22077) 2025-12-19 14:29:52 +01:00
strawberry.lock [ty] Lockfiles for mdtests with external dependencies (#22077) 2025-12-19 14:29:52 +01:00
strawberry.md [ty] Improve rendering of default values for function args (#22010) 2025-12-16 13:39:19 -05:00

README.md

mdtests with external dependencies

This directory contains mdtests that make use of external packages. See the mdtest README.md for more information.