ruff
1d20cf95 - [ty] Add hint if async context manager is used in non-async with statement (#18299)

Commit
203 days ago
[ty] Add hint if async context manager is used in non-async with statement (#18299) # Summary Adds a subdiagnostic hint in the following scenario where a synchronous `with` is used with an async context manager: ```py class Manager: async def __aenter__(self): ... async def __aexit__(self, *args): ... # error: [invalid-context-manager] "Object of type `Manager` cannot be used with `with` because it does not implement `__enter__` and `__exit__`" # note: Objects of type `Manager` *can* be used as async context managers # note: Consider using `async with` here with Manager(): ... ``` closes https://github.com/astral-sh/ty/issues/508 ## Test Plan New MD snapshot tests --------- Co-authored-by: David Peter <mail@david-peter.de>
Author
Parents
Loading