ruff
a9be810c - [ty] Type inference for `@asynccontextmanager` (#21876)

Commit
18 hours ago
[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
Author
Parents
Loading