Skip to content

Remove some uses of inlineCallbacks to improve type checkability #520

@exarkun

Description

@exarkun

inlineCallbacks introduces two problems for type checking. First, it creates a decorator function that has a signature that is effectively:

def f(*a: Any, **kw: Any) -> T:

This means all possible calls to the function are allowed by a type checker, removing almost all value that a type checker could provide related to the function.

Second, GridSync's TwistedDeferred[T] makes the yield and send type of the generator Deferred[Any] and Any respectively. This makes the result of all yields and all future operations on them allowed, similarly removing almost all value that a type checker could provide.

async def is easier to annotate specifically such that a type checker can provide some value. And async def is otherwise basically feature equivalent to inlineCallbacks. So, GridSync should switch from inlineCallbacks to async def.

I propose to do this to gridsync/rootcap.py for now, to enable a refactoring to use tahoe-capabilities in support of #449.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions