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 type hints to test_authentication.py #2472

Merged
merged 10 commits into from
Feb 6, 2024

Conversation

TechNiick
Copy link
Contributor

@TechNiick TechNiick commented Feb 4, 2024

Summary

Related to this
Type annotation added to test_authentication.py

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

@TechNiick TechNiick changed the title Added type annotations to test_authentication.py Added type hints to test_authentication.py Feb 4, 2024
@Kludex Kludex changed the title Added type hints to test_authentication.py Add type hints to test_authentication.py Feb 5, 2024
@@ -1,9 +1,16 @@
import base64
import binascii
import sys
from typing import Any, Awaitable, Callable, Optional, Tuple
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid use Any, please.

from starlette.testclient import TestClient
from starlette.websockets import WebSocket, WebSocketDisconnect

P = ParamSpec("P")
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I have added it on **kwargs: P.kwargs.

@TechNiick TechNiick requested a review from Kludex February 5, 2024 22:23
def ws_inject_decorator(**kwargs):
def wrapper(endpoint):
def app(websocket):
def ws_inject_decorator(**kwargs: P.kwargs) -> Callable[..., AsyncEndpoint]: # type: ignore
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def ws_inject_decorator(**kwargs: P.kwargs) -> Callable[..., AsyncEndpoint]: # type: ignore
def ws_inject_decorator(**kwargs: Any) -> Callable[..., AsyncEndpoint]:

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P is wrong.

@TechNiick TechNiick requested a review from Kludex February 6, 2024 20:15
@Kludex Kludex enabled auto-merge (squash) February 6, 2024 20:47
@Kludex Kludex merged commit 0e4da0a into encode:master Feb 6, 2024
5 checks passed
nixroxursox pushed a commit to nixroxursox/starlette that referenced this pull request Mar 18, 2024
* added type annotations to test_authentication.py

* fixed types

* Apply suggestions from code review

* Fix linting

* Fix linting

* Apply suggestions from code review

---------

Co-authored-by: Scirlat Danut <scirlatdanut@scirlats-mini.lan>
Co-authored-by: Marcelo Trylesinski <marcelotryle@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.

2 participants