Skip to content
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

Add hints to generics in Route.respond #284

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JacobHayes
Copy link

The json parameter to Route.respond is missing hints for the List and Dict elements, which makes pyright sad in strict mode:

.../tests/test_url.py:6:5 - error: Type of "respond" is partially unknown
    Type of "respond" is "(status_code: int = 200, *, headers: Headers | Dict[str, str] | Dict[bytes, bytes] | Sequence[Tuple[str, str]] | Sequence[Tuple[bytes, bytes]] | None = None, cookies: Dict[str, str] | Sequence[Tuple[str, str]] | Sequence[SetCookie] | None = None, content: str | bytes | Iterable[bytes] | AsyncIterable[bytes] | None = None, text: str | None = None, html: str | None = None, json: str | List[Unknown] | Dict[Unknown, Unknown] | None = None, stream: SyncByteStream | AsyncByteStream | None = None, content_type: str | None = None, http_version: str | None = None, **kwargs: Any) -> Route" (reportUnknownMemberType)
1 error, 0 warnings, 0 informations

This PR just adds the hints for the elements. I think python's json.dump will accept arbitrary key types, but the JSON spec only defines strings so I used Dict[str, ...]. I'm happy to change that to Any if you'd prefer.

Thanks for the helpful library!

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.

1 participant