storage.UserProtocol: allow for read-only attributes#1582
Merged
nijel merged 3 commits intopython-social-auth:masterfrom Feb 24, 2026
Merged
storage.UserProtocol: allow for read-only attributes#1582nijel merged 3 commits intopython-social-auth:masterfrom
storage.UserProtocol: allow for read-only attributes#1582nijel merged 3 commits intopython-social-auth:masterfrom
Conversation
This loosens the restrictions on the `social_core.storage.UserProtocol` attributes to allow for read-only attributes by changing them from mutable attributes to properties. This is a backwards compatible change. The properties might look a bit odd here, but because there is no way to better way express read-only attributes in Python, this is the conventional way to express this, and is understood by all major type-checkers.
Member
|
The test model will need some adjustment for this because it now assigns to a read-only property: social-core/social_core/tests/models.py Line 50 in aed39e6 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1582 +/- ##
==========================================
- Coverage 79.16% 79.15% -0.01%
==========================================
Files 354 354
Lines 11661 11658 -3
Branches 536 536
==========================================
- Hits 9231 9228 -3
Misses 2245 2245
Partials 185 185
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
Merged, thanks for your contribution! |
Contributor
Author
|
Happy to help. And thank you for upping the static typing game here :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This loosens the restrictions on the
social_core.storage.UserProtocolattributes to allow for read-only attributes by changing them from mutable attributes to properties. This is a backwards compatible change. The properties might look a bit odd here, but because there is no way to better way express read-only attributes in Python, this is the conventional way to express this, and is understood by all major type-checkers.I ran into this issue in my django project when trying to pass an instance of
AbstractUsertocreate_social_auth.This (basedpyright) error appeared after upgrading
social-auth-corefrom4.8.3to4.8.5. I did not try other type-checkers, but I'm pretty certain they'd also report a similar error.