Skip to content

Type checking fails when using constructor overrides in arrayconnection.py  #32

Closed
@markedwards

Description

@markedwards

Overriding one of the type constructors in one of the resolvers in arrayconnection.py breaks the return type of resolver.

For instance:

@dataclass
class CustomConnection:
    edges: List[Edge]
    pageInfo: PageInfo

# connection is typed as Connection, but it is actually CustomConnection
connection = connection_from_array(
    [], 
    connection_type=CustomConnection,
)

As with issue #29, this can be cleanly resolved using custom Protocol definitions, although there is the downside noted in that issue of the additional typing-extensions dependency.

Unlike the other issue, I think you could implement a partial solution using Callable, TypeVar, and overload from typing, without having the Protocol dependency. I'm pretty sure the resulting code would be extremely difficult to understand though, and it would be very verbose.

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