ruff/crates/ty_python_semantic/resources/mdtest/external
David Peter a9be810c38
[ty] Type inference for `@asynccontextmanager` (#21876)
## Summary

This PR adds special handling for `asynccontextmanager` calls as a
temporary solution for https://github.com/astral-sh/ty/issues/1804. We
will be able to remove this soon once we have support for generic
protocols in the solver.

closes https://github.com/astral-sh/ty/issues/1804

## Ecosystem

```diff
+ tests/test_downloadermiddleware.py:305:56: error[invalid-argument-type] Argument to bound method `download` is incorrect: Expected `Spider`, found `Unknown | Spider | None`
+ tests/test_downloadermiddleware.py:305:56: warning[possibly-missing-attribute] Attribute `spider` may be missing on object of type `Crawler | None`
```
These look like true positives

```diff
+ pymongo/asynchronous/database.py:1021:35: error[invalid-assignment] Object of type `(AsyncClientSession & ~AlwaysTruthy & ~AlwaysFalsy) | (_ServerMode & ~AlwaysFalsy) | Unknown | Primary` is not assignable to `_ServerMode | None`
+ pymongo/asynchronous/database.py:1025:17: error[invalid-argument-type] Argument to bound method `_conn_for_reads` is incorrect: Expected `_ServerMode`, found `_ServerMode | None`
```

Known problems or true positives, just caused by the new type for
`session`

```diff
- src/integrations/prefect-sqlalchemy/prefect_sqlalchemy/database.py:269:16: error[invalid-return-type] Return type does not match returned value: expected `Connection | AsyncConnection`, found `_GeneratorContextManager[Unknown, None, None] | _AsyncGeneratorContextManager[Unknown, None] | Connection | AsyncConnection`
+ src/integrations/prefect-sqlalchemy/prefect_sqlalchemy/database.py:269:16: error[invalid-return-type] Return type does not match returned value: expected `Connection | AsyncConnection`, found `_GeneratorContextManager[Unknown, None, None] | _AsyncGeneratorContextManager[AsyncConnection, None] | Connection | AsyncConnection`
```

Just a more concrete type

```diff
- src/prefect/flow_engine.py:1277:24: error[missing-argument] No argument provided for required parameter `cls`
- src/prefect/server/api/server.py:696:49: error[missing-argument] No argument provided for required parameter `cls`
- src/prefect/task_engine.py:1426:24: error[missing-argument] No argument provided for required parameter `cls`
```

Good

## Test Plan

* Adapted and newly added Markdown tests
* Tested on internal codebase
2025-12-09 22:49:00 +01:00
..
README.md [ty] mdtests with external dependencies (#20904) 2025-12-08 11:44:20 +01:00
attrs.md [ty] mdtests with external dependencies (#20904) 2025-12-08 11:44:20 +01:00
numpy.md [ty] mdtests with external dependencies (#20904) 2025-12-08 11:44:20 +01:00
pydantic.md [ty] mdtests with external dependencies (#20904) 2025-12-08 11:44:20 +01:00
pytest.md [ty] mdtests with external dependencies (#20904) 2025-12-08 11:44:20 +01:00
sqlalchemy.md [ty] Infer type variables within generic unions (#21862) 2025-12-09 16:22:59 +01:00
sqlmodel.md [ty] Type inference for `@asynccontextmanager` (#21876) 2025-12-09 22:49:00 +01:00
strawberry.md [ty] mdtests with external dependencies (#20904) 2025-12-08 11:44:20 +01: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.