Skip to content

gitea.resource.protocol

protocol

What a resource needs of the client that owns it.

Resource and AsyncResource reach for exactly one thing on their client: _request. Naming that as a protocol here, rather than importing the concrete Gitea and AsyncGitea, is what keeps the dependency running one way. The clients build the resources, so a resource that imported its client back - even under TYPE_CHECKING - would close a cycle across most of the package.

Neither protocol is runtime_checkable, and nothing here is meant to be subclassed: Gitea and AsyncGitea satisfy these structurally, by having the method, and a test double satisfies them the same way.

Classes

gitea.resource.protocol.ClientProtocol

Bases: Protocol

The part of a synchronous client that a Resource uses.

gitea.resource.protocol.AsyncClientProtocol

Bases: Protocol

The part of an asynchronous client that an AsyncResource uses.