12
113
Fork
You've already forked django-allauth
149

refactor(socialaccount): lift settings-backed SocialApp construction out of list_apps #4763

Open
bufke wants to merge 1 commit from bufke/django-allauth:refactor-list-apps-from-settings into main
pull from: bufke/django-allauth:refactor-list-apps-from-settings
merge into: allauth:main
allauth:main
allauth:fix/account-middleware-reauth-exc-vs-api
allauth:65.12.x
allauth:65.11.x
allauth:feat/openid-connect-id-token
allauth:fix/phone-vs-social-signup
allauth:65.8.x
allauth:feat/idp
allauth:feat/resend-code-or-change
allauth:fix/phone-signup-conflict
allauth:feat/phone
allauth:fix/headless-email-verification-by-code
allauth:fix/a11y
allauth:feat/facebook-limited-login
allauth:fix/headless-only-connect-reauth
allauth:fix/email-added-vs-code-verification
allauth:feat/login-required-middleware
allauth:0.63.x
allauth:refactor-unique-true-field
allauth:0.62.x
allauth:0.57.x
allauth:0.60.x
allauth:0.55.x
allauth:feat-metamask
Contributor
Copy link

Refactor out _build_apps_from_settings - an io-free function. While called only once, IMO it's easier to read and gets some extra io-free testing. I have one more io-free function refactor I will submit. I'm not including any trivial ones that mainly benefit asyncio while making core neutral or worse in terms of lines of code and readability.

I used the _ prefix to indicate private. I saw this done sometimes in the code base but it could go either way.

Generated by Claude, reviewed by me.

General

  • Make sure you use semantic commit messages.
    Examples: "fix(google): Fixed foobar bug", "feat(accounts): Added foobar feature".
  • All Python code must formatted using Black, and clean from pep8 and isort issues.
  • JavaScript code should adhere to StandardJS.
  • If your changes are significant, please update ChangeLog.rst.
  • If your change is substantial, feel free to add yourself to AUTHORS.
Refactor out _build_apps_from_settings - an io-free function. While called only once, IMO it's easier to read and gets some extra io-free testing. I have one more io-free function refactor I will submit. I'm not including any trivial ones that mainly benefit asyncio while making core neutral or worse in terms of lines of code and readability. I used the _ prefix to indicate private. I saw this done sometimes in the code base but it could go either way. Generated by Claude, reviewed by me. ## General - [x] Make sure you use [semantic commit messages](https://seesparkbox.com/foundry/semantic_commit_messages). Examples: `"fix(google): Fixed foobar bug"`, `"feat(accounts): Added foobar feature"`. - [x] All Python code must formatted using Black, and clean from pep8 and isort issues. - [ ] JavaScript code should adhere to [StandardJS](https://standardjs.com). - [ ] If your changes are significant, please update `ChangeLog.rst`. - [ ] If your change is substantial, feel free to add yourself to `AUTHORS`.
refactor(socialaccount): lift settings-backed SocialApp construction out of list_apps
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
5491b65656
`DefaultSocialAccountAdapter.list_apps` mixed database I/O (querying
`SocialApp` rows) with pure, settings-driven construction of `SocialApp`
instances from `SOCIALACCOUNT_PROVIDERS`. This made the settings-config
handling impossible to exercise without a database.
Extract the pure pieces into two module-level helpers:
- `build_apps_from_settings(*, provider=None, client_id=None) -> dict`
 builds the `provider -> [SocialApp]` map from settings, with no DB
 access. The field-copy list, the `certificate_key` deprecation warning,
 and the `client_id`/`provider` filtering are preserved identically.
- `flatten_apps(provider_to_apps) -> list` flattens the map, preserving
 per-provider insertion order.
`list_apps` still queries the DB, merges the settings-backed apps into the
same map via `setdefault(...).extend(...)`, and returns `flatten_apps(...)`,
so ordering and dedup behavior are unchanged. No public API changes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
bufke force-pushed refactor-list-apps-from-settings from 5491b65656
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
to 4e3668426d
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
2026年07月08日 18:56:53 +02:00
Compare
Some checks are pending
ci/woodpecker/pr/woodpecker/1 Pipeline is pending approval
ci/woodpecker/pr/woodpecker/2 Pipeline is pending approval
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u refactor-list-apps-from-settings:bufke-refactor-list-apps-from-settings
git switch bufke-refactor-list-apps-from-settings

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff bufke-refactor-list-apps-from-settings
git switch bufke-refactor-list-apps-from-settings
git rebase main
git switch main
git merge --ff-only bufke-refactor-list-apps-from-settings
git switch bufke-refactor-list-apps-from-settings
git rebase main
git switch main
git merge --no-ff bufke-refactor-list-apps-from-settings
git switch main
git merge --squash bufke-refactor-list-apps-from-settings
git switch main
git merge --ff-only bufke-refactor-list-apps-from-settings
git switch main
git merge bufke-refactor-list-apps-from-settings
git push origin main
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
allauth/django-allauth!4763
Reference in a new issue
allauth/django-allauth
No description provided.
Delete branch "bufke/django-allauth:refactor-list-apps-from-settings"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?