Skip to content

Add type hints to hpack #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

sethmlarson
Copy link
Member

No description provided.

@sethmlarson sethmlarson requested a review from Kriechi February 27, 2021 03:31
@Kriechi
Copy link
Member

Kriechi commented Feb 27, 2021

Tests are still failing - but otherwise this LGTM!

@sethmlarson
Copy link
Member Author

Disappointed by the amount of # type: ignore required. Going to manually take another look before merging.

@graingert
Copy link

graingert commented Apr 17, 2021

PR for stricter #type: ignore[...] https://github.com/sethmlarson/hpack/pull/1/files

seems that you can't do Tuple[AnyStr, AnyStr] perhaps it would be better to make frozen attrs classes?

class HeaderTupleLike(Prototocol[AnyStr]):
    name: AnyStr
    value: AnyStr
    indexed: bool

@attr.frozen
class HeaderTuple(Generic[AnyStr]):
    name: AnyStr
    value: AnyStr
    indexed: Literal[True] = attr.field(default=True, init=False)

@attr.frozen
class NeverIndexedHeaderTuple(Generic[AnyStr]):
    name: AnyStr
    value: AnyStr
    indexed: Literal[False] = attr.field(default=False, init=False)

it's unfortunate that this extension of a builtin is part of the public interface though

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants