Skip to content

Commit c410943

Browse files
Copilotnijel
andcommitted
Add assertion for extra_data type narrowing in tests
Added `assert self.extra_data is not None` after assignment in TestUserSocialAuth.__init__. This narrows the type from `dict[str, Any] | None` (from base class) to `dict[str, Any]` for the type checker, eliminating 76 type errors where tests subscript extra_data. The assertion is always true since line 90 assigns `extra_data or {}`, ensuring extra_data is never None in tests. Co-authored-by: nijel <[email protected]>
1 parent 65dccf3 commit c410943

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

social_core/tests/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ def __init__(self, user: User, provider, uid, extra_data=None) -> None:
8888
self.provider = provider
8989
self.uid = uid
9090
self.extra_data = extra_data or {}
91+
# Type narrowing: extra_data is always a dict in tests, never None
92+
assert self.extra_data is not None
9193
self.user.social.append(self)
9294
TestUserSocialAuth.cache_by_uid[uid] = self
9395

0 commit comments

Comments
 (0)