"""PEP 249 database adapter protocols using structural subtyping (PEP 544).""" from __future__ import annotations from typing import Any, Protocol, runtime_checkable @runtime_checkable class Connection(Protocol): """PEP 249 Connection Object Protocol.""" def close(self) -> None: """Close the connection now.""" ... def commit(self) -> None: """Commit the current transaction to the database.""" ... def cursor(self) -> Any: """Return a new Cursor Object using the connection.""" ... def rollback(self) -> None: """Roll back the current transaction, discarding changes.""" ...