-
-
Notifications
You must be signed in to change notification settings - Fork 571
Fix type errors from ty v0.0.1a25 upgrade #1401
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
Changes from 7 commits
0e53252
2016eef
404c1dc
810b8b6
2e58511
ae20876
beb42bb
53f0c87
fc82ba8
09630fa
6ee6663
a83cca2
5164e4f
eaf9c84
f137f4f
3600f1c
a7573b2
939725d
d66e21d
99d802b
7aa612b
bf66726
84ab57c
34dfdd7
65dccf3
c410943
5de7184
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,19 @@ | ||
| # pyright: reportAttributeAccessIssue=false | ||
|
|
||
| import json | ||
| from typing import TYPE_CHECKING, Any, Protocol | ||
|
|
||
| from .oauth import OAuth2PkceS256Test | ||
|
|
||
| if TYPE_CHECKING: | ||
|
|
||
| class _OAuth2PkceS256TestProtocol(Protocol): | ||
| """Protocol for OAuth2PkceS256Test methods used by mixins.""" | ||
|
|
||
| def assertEqual(self, first: Any, second: Any, msg: Any = None) -> None: ... | ||
|
||
| def do_login(self) -> Any: ... | ||
| def do_refresh_token(self) -> Any: ... | ||
|
|
||
|
|
||
| class EtsyOAuth2Mixin: | ||
| backend_path = "social_core.backends.etsy.EtsyOAuth2" | ||
|
|
@@ -36,7 +46,7 @@ class EtsyOAuth2Mixin: | |
| ) | ||
| expected_username = "dummy_user_id" | ||
|
|
||
| def test_login(self) -> None: | ||
| def test_login(self: "_OAuth2PkceS256TestProtocol") -> None: # type: ignore[misc] | ||
| user = self.do_login() | ||
| self.assertEqual(len(user.social), 1) | ||
|
|
||
|
|
@@ -58,7 +68,7 @@ def test_login(self) -> None: | |
| social.extra_data["refresh_token"], "dummy_user_id.dummy_refresh_token" | ||
| ) | ||
|
|
||
| def test_refresh_token(self) -> None: | ||
| def test_refresh_token(self: "_OAuth2PkceS256TestProtocol") -> None: # type: ignore[misc] | ||
| _, social = self.do_refresh_token() | ||
|
|
||
| self.assertEqual(social.uid, "dummy_user_id") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| # pyright: reportAttributeAccessIssue=false | ||
|
|
||
| import json | ||
| from typing import TYPE_CHECKING, Any, Protocol | ||
|
|
||
| from social_core.exceptions import AuthException | ||
|
|
||
|
|
@@ -11,6 +12,15 @@ | |
| OAuth2Test, | ||
| ) | ||
|
|
||
| if TYPE_CHECKING: | ||
|
|
||
| class _OAuth2TestProtocol(Protocol): | ||
| """Protocol for OAuth2Test methods used by mixins.""" | ||
|
|
||
| def assertEqual(self, first: Any, second: Any, msg: Any = None) -> None: ... | ||
|
||
| def do_login(self) -> Any: ... | ||
| def do_partial_pipeline(self) -> Any: ... | ||
|
|
||
|
|
||
| class TwitterOAuth2Mixin: | ||
| backend_path = "social_core.backends.twitter_oauth2.TwitterOAuth2" | ||
|
|
@@ -80,7 +90,7 @@ class TwitterOAuth2Mixin: | |
|
|
||
| expected_username = "twitter_username" | ||
|
|
||
| def test_login(self) -> None: | ||
| def test_login(self: "_OAuth2TestProtocol") -> None: # type: ignore[misc] | ||
| user = self.do_login() | ||
|
|
||
| self.assertEqual(len(user.social), 1) | ||
|
|
@@ -106,7 +116,7 @@ def test_login(self) -> None: | |
| self.assertEqual(social.extra_data["public_metrics"]["tweet_count"], 40) | ||
| self.assertEqual(social.extra_data["public_metrics"]["listed_count"], 7) | ||
|
|
||
| def test_partial_pipeline(self) -> None: | ||
| def test_partial_pipeline(self: "_OAuth2TestProtocol") -> None: # type: ignore[misc] | ||
| user = self.do_partial_pipeline() | ||
| self.assertEqual(len(user.social), 1) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type annotation for
assertEqualis incorrect. The unittest.TestCase'sassertEqualmethod returnsNone, notAny. The signature should be:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
assertEqualmethod already has the correct return type-> Nonein the current code (line 15 in test_bitbucket_datacenter.py). No changes needed.