Fix mypy context manager typing for adapter subclasses.
Return Self from __enter__ so with-blocks preserve subclass types, and align mypy python_version with the 3.12 runtime target. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
co-authored by
Cursor
parent
e98fd3b90d
commit
497533f0e3
@@ -3,13 +3,14 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Self
|
||||
|
||||
|
||||
class ContextAwareInterface(ABC):
|
||||
"""Interface that defines context-related methods."""
|
||||
|
||||
@abstractmethod
|
||||
def __enter__(self) -> ContextAwareInterface:
|
||||
def __enter__(self) -> Self:
|
||||
"""Enter the context."""
|
||||
...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user