Skip to content

converter expected to return a Tuple where perhaps an Iterable should do #474

Closed
@wsanchez

Description

@wsanchez

After updating mypy from 0.630 to 0.650 for Klein, I get this error:

src/klein/_headers.py:172:18: error: Argument "converter" to "attrib" has incompatible type "Callable[[Iterable[Iterable[bytes]]], Sequence[Tuple[bytes, bytes]]]"; expected "Optional[Callable[[Any], Tuple[]]]"

If I'm reading this correctly, the provided converter is a Callable (OK) and takes one argument (OK) and returns a Sequence (not OK: Tuple expected).

The converter specified in src/klein/_headers.py:172 is normalizeRawHeadersFrozen:

def normalizeRawHeadersFrozen(headerPairs):
    # type: (Iterable[Iterable[bytes]]) -> RawHeaders
    return tuple(normalizeRawHeaders(headerPairs))

This implementation does return a tuple, but I wanted to limit my commitment to a Sequence. I think that converter should be happy with a Sequence in practice, so I'd like to lobby for a looser requirement here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions