internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: pennersr/django-allauth

Issue:
Update Facebook complete login
Users may want to create custom provider which extends FacebookProvider and set custom provider_id.

For example
```
from allauth.socialaccount.providers.facebook.provider import FacebookProvider


class FacebookGroupProvider(FacebookProvider):
    id = "facebook_group"
    name = "Facebook Group"


provider_classes = [FacebookGroupProvider]
```

The problem is in this case social account will be created with FacebookProvider.id instead of custom provider_id.

https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/providers/facebook/views.py#L66
https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/providers/facebook/views.py#L38
https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/providers/facebook/views.py#L49
https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/providers/base.py#L63
https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/providers/base.py#L86

I think we don't need to update [login_by_token](https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/providers/facebook/views.py#L73) function for custom provider.
Because we use this function for Facebook login purpose.


Discussion:

Resolving patch:
diff --git a/allauth/socialaccount/providers/facebook/views.py b/allauth/socialaccount/providers/facebook/views.py
--- a/allauth/socialaccount/providers/facebook/views.py
+++ b/allauth/socialaccount/providers/facebook/views.py
@@ -35,7 +35,7 @@ def compute_appsecret_proof(app, token):
 
 
 def fb_complete_login(request, app, token):
-    provider = providers.registry.by_id(FacebookProvider.id, request)
+    provider = providers.registry.by_id(app.provider, request)
     resp = requests.get(
         GRAPH_API_URL + "/me",
         params={


Test patch:
Repository: pennersr/django-allauth

Issue:
Allowing specyfing a token parameter displayed in password reset URLs.
### Allow customizing PasswordResetConfirmView's INTERNAL_RESET_URL_TOKEN

I propose to update [PasswordResetFromKeyView](https://github.com/pennersr/django-allauth/blob/c50a30acc0e4553297b0ddb697d55a290ed6d038/allauth/account/views.py#L715) according to [Django ticket](https://code.djangoproject.com/ticket/28780) with [related PR to it](https://github.com/django/django/commit/58df8aa40fe88f753ba79e091a52f236246260b3).


Also, for me it was important to extend `PasswordResetFromKeyView` view and I found out that it uses internally in dispatch method [self.request.path.replace()](https://github.com/pennersr/django-allauth/blob/c50a30acc0e4553297b0ddb697d55a290ed6d038/allauth/account/views.py#L759) instead of `self.request.get_full_path()` for keeping my query string in URL after redirecting for hiding key in session.


Discussion:
Makes sense, can you prep a PR?
Hi @pennersr ,
Sure, I can. I will ping you when it will be ready.

Resolving patch:
diff --git a/allauth/account/views.py b/allauth/account/views.py
--- a/allauth/account/views.py
+++ b/allauth/account/views.py
@@ -44,7 +44,6 @@
 )
 
 
-INTERNAL_RESET_URL_KEY = "set-password"
 INTERNAL_RESET_SESSION_KEY = "_password_reset_key"
 
 
@@ -726,6 +725,7 @@ class PasswordResetFromKeyView(
     template_name = "account/password_reset_from_key." + app_settings.TEMPLATE_EXTENSION
     form_class = ResetPasswordKeyForm
     success_url = reverse_lazy("account_reset_password_from_key_done")
+    internal_reset_url_key = "set-password"
 
     def get_form_class(self):
         return get_form_class(
@@ -736,7 +736,7 @@ def dispatch(self, request, uidb36, key, **kwargs):
         self.request = request
         self.key = key
 
-        if self.key == INTERNAL_RESET_URL_KEY:
+        if self.key == self.internal_reset_url_key:
             self.key = self.request.session.get(INTERNAL_RESET_SESSION_KEY, "")
             # (Ab)using forms here to be able to handle errors in XHR #890
             token_form = UserTokenForm(data={"uidb36": uidb36, "key": self.key})
@@ -765,7 +765,7 @@ def dispatch(self, request, uidb36, key, **kwargs):
                 # HTTP Referer header.
                 self.request.session[INTERNAL_RESET_SESSION_KEY] = self.key
                 redirect_url = self.request.path.replace(
-                    self.key, INTERNAL_RESET_URL_KEY
+                    self.key, self.internal_reset_url_key
                 )
                 return redirect(redirect_url)
 


Test patch:
Repository: pennersr/django-allauth

Issue:
Add python 3.10 support
Would maintainers be willing to add python 3.10 to tox tests and official support? You can add this with the `py310` tag according the tox's [changelog](https://tox.wiki/en/latest/changelog.html#id158). 


Discussion:
Yes, feel free to submit a PR.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -157,6 +157,7 @@ def find_package_data(
         "Programming Language :: Python :: 3.7",
         "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.9",
+        "Programming Language :: Python :: 3.10",
         "Framework :: Django",
         "Framework :: Django :: 2.0",
         "Framework :: Django :: 2.1",


Test patch:
Repository: pennersr/django-allauth

Issue:
Gitea provider does not work by default with gitea.com
It seems the Gitea provider expects a [/user](https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/providers/gitea/views.py#L25) endpoint. But this 404's. It appears the Gitea project added a `login/oauth/userinfo` endpoint for this instead. The new endpoint uses "sub" for the ID instead of "id" as well. @techknowlogick it looks like you created the original provider, perhaps you know more about it?

# Reproduction steps

- Register application, https://gitea.com/user/settings/applications/
- Add Social App via Django Admin
- Attempt to log in


Discussion:
It shouldn't 404, as that's a pretty well-used endpoint (more details on it here: https://try.gitea.io/api/swagger#/user/userGetCurrent), can you give logs from gitea when it attempts to fetch that endpoint?
Ah I see the issue, it defaults to use gitea.com but the default api url ends up being `gitea.com/user` instead of `gitea.com/api/v1/user`. 

```
    if "GITEA_URL" in settings:
        web_url = settings.get("GITEA_URL").rstrip("/")
        api_url = "{0}/api/v1".format(web_url)
    else:
        web_url = "https://gitea.com"
        api_url = "https://gitea.com"
```

should be something like

```
    if "GITEA_URL" in settings:
        web_url = settings.get("GITEA_URL").rstrip("/")
    else:
        web_url = "https://gitea.com"
    api_url = "{0}/api/v1".format(web_url)
```

Resolving patch:
diff --git a/allauth/socialaccount/providers/gitea/views.py b/allauth/socialaccount/providers/gitea/views.py
--- a/allauth/socialaccount/providers/gitea/views.py
+++ b/allauth/socialaccount/providers/gitea/views.py
@@ -15,10 +15,9 @@ class GiteaOAuth2Adapter(OAuth2Adapter):
 
     if "GITEA_URL" in settings:
         web_url = settings.get("GITEA_URL").rstrip("/")
-        api_url = "{0}/api/v1".format(web_url)
     else:
         web_url = "https://gitea.com"
-        api_url = "https://gitea.com"
+    api_url = "{0}/api/v1".format(web_url)
 
     access_token_url = "{0}/login/oauth/access_token".format(web_url)
     authorize_url = "{0}/login/oauth/authorize".format(web_url)


Test patch:
Repository: pennersr/django-allauth

Issue:
empty user.email for keycloak
I found a bug introduced by #3165 regarding the `user.email` field with the `keycloak` provider (possibly other OIDC providers too). 

After a successful login, the `user.email` attribute is empty but was filled in with django-allauth 0.51.0.

I think the problem is in [extract_common_fields](https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/providers/openid_connect/provider.py#L43), which doesn't return the `email` attribute anymore, but that would be needed for [populate_user](https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/providers/base/provider.py#L75) that updates the user field.


Discussion:

Resolving patch:
diff --git a/allauth/socialaccount/providers/openid_connect/provider.py b/allauth/socialaccount/providers/openid_connect/provider.py
--- a/allauth/socialaccount/providers/openid_connect/provider.py
+++ b/allauth/socialaccount/providers/openid_connect/provider.py
@@ -42,6 +42,7 @@ def extract_uid(self, data):
 
     def extract_common_fields(self, data):
         return dict(
+            email=data.get("email"),
             username=data.get("preferred_username"),
             name=data.get("name"),
             user_id=data.get("user_id"),


Test patch:
Repository: pennersr/django-allauth

Issue:
`OpenIDConnectProvider` generates slug using `_server_id` and does not fallback to inherited implementation
KeycloakProvider started using `openid_connect` as its base url since the `OpenIDConnectProvider` implemented `get_slug` 


Discussion:

Resolving patch:
diff --git a/allauth/socialaccount/providers/openid_connect/provider.py b/allauth/socialaccount/providers/openid_connect/provider.py
--- a/allauth/socialaccount/providers/openid_connect/provider.py
+++ b/allauth/socialaccount/providers/openid_connect/provider.py
@@ -32,7 +32,7 @@ def token_auth_method(self):
 
     @classmethod
     def get_slug(cls):
-        return cls._server_id if cls._server_id else "openid_connect"
+        return cls._server_id or super().get_slug()
 
     def get_default_scope(self):
         return ["openid", "profile", "email"]


Test patch:
Repository: pennersr/django-allauth

Issue:
Feature Request: Prefill option for E-Mail on signup form
Hi,

would be nice if I could send a link to a customer with a prefilled version of the registration form.

For example:
https://www.exmaple.com/accounts/signup/?email=cumter@email.de


Discussion:
Implemented on PR #3003 
i got the same thought, too. This would be amazing!

Resolving patch:
diff --git a/allauth/account/views.py b/allauth/account/views.py
--- a/allauth/account/views.py
+++ b/allauth/account/views.py
@@ -2,6 +2,8 @@
 from django.contrib.auth import REDIRECT_FIELD_NAME
 from django.contrib.auth.decorators import login_required
 from django.contrib.sites.shortcuts import get_current_site
+from django.core.validators import validate_email
+from django.forms import ValidationError
 from django.http import (
     Http404,
     HttpResponsePermanentRedirect,
@@ -290,6 +292,19 @@ def get_context_data(self, **kwargs):
         )
         return ret
 
+    def get_initial(self):
+        initial = super().get_initial()
+        email = self.request.GET.get("email")
+        if email:
+            try:
+                validate_email(email)
+            except ValidationError:
+                return initial
+            initial["email"] = email
+            if app_settings.SIGNUP_EMAIL_ENTER_TWICE:
+                initial["email2"] = email
+        return initial
+
 
 signup = SignupView.as_view()
 


Test patch:
diff --git a/allauth/account/tests/test_signup.py b/allauth/account/tests/test_signup.py
--- a/allauth/account/tests/test_signup.py
+++ b/allauth/account/tests/test_signup.py
@@ -10,6 +10,7 @@
 from django.test.utils import override_settings
 from django.urls import reverse
 
+import pytest
 from pytest_django.asserts import assertTemplateUsed
 
 from allauth.account import app_settings
@@ -371,3 +372,16 @@ def test_prevent_enumeration_on(settings, user_factory):
     assert resp.context["form"].errors == {
         "email": ["A user is already registered with this email address."]
     }
+
+
+@pytest.mark.django_db
+def test_get_initial_with_valid_email():
+    """Test that the email field is populated with a valid email."""
+    request = RequestFactory().get("/signup/?email=test@example.com")
+    from allauth.account.views import signup
+
+    SessionMiddleware(lambda request: None).process_request(request)
+    request.user = AnonymousUser()
+    with context.request_context(request):
+        view = signup(request)
+    assert view.context_data["view"].get_initial()["email"] == "test@example.com"
Repository: pennersr/django-allauth

Issue:
login_required CBV consistency
Hello, I came across a case where I subclassed allauth.socialaccount.views.ConnectionsView and was missing the login required check. Unlike the rest of the CBVs in allauth that require a logged in user, the login_required decorator is called in the method for the urls instead.

```
# Currently
connections = login_required(ConnectionsView.as_view())

# instead replace with decorator?
@method_decorator(login_required, name="dispatch")
class ConnectionsView(AjaxCapableProcessFormViewMixin, FormView):
```

Is there any harm in moving this up to the class like all the other CBVs? Happy to submit a PR if it's ok and I'm not missing something.

Thank you!!


Discussion:
You're right -- a pull request is welcome!

Resolving patch:
diff --git a/allauth/socialaccount/views.py b/allauth/socialaccount/views.py
--- a/allauth/socialaccount/views.py
+++ b/allauth/socialaccount/views.py
@@ -2,6 +2,7 @@
 from django.contrib.sites.shortcuts import get_current_site
 from django.http import HttpResponseRedirect
 from django.urls import reverse, reverse_lazy
+from django.utils.decorators import method_decorator
 from django.views.generic.base import TemplateView
 from django.views.generic.edit import FormView
 
@@ -86,6 +87,7 @@ class LoginErrorView(TemplateView):
 login_error = LoginErrorView.as_view()
 
 
+@method_decorator(login_required, name="dispatch")
 class ConnectionsView(AjaxCapableProcessFormViewMixin, FormView):
     template_name = "socialaccount/connections." + account_settings.TEMPLATE_EXTENSION
     form_class = DisconnectForm
@@ -117,4 +119,4 @@ def get_ajax_data(self):
         return {"socialaccounts": account_data}
 
 
-connections = login_required(ConnectionsView.as_view())
+connections = ConnectionsView.as_view()


Test patch:
Repository: pennersr/django-allauth

Issue:
Headless `SessionView` for `APP` client creates an unnecessary session
In an `APP` context, when the client invokes DELETE on `SessionView`, a new empty and useless session is created in the session store and an associated session token is present in the response. Because this new session is empty, it can't be used to authenticate, so fortunately there isn't any security issue related to this.

In short, the following test fails:
```python
def test_logout_no_token(app_client, user):
    app_client.force_login(user)
    resp = app_client.get(reverse("headless:app:account:current_session"))
    assert resp.status_code == 200
    resp = app_client.delete(reverse("headless:app:account:current_session"))
    assert resp.status_code == 401
    assert "session_token" not in resp.json()["meta"]
```

The problem is that Django's `logout()` function flushes the session which sets `session.modified = True`, but `expose_session_token()` attempts to create a new session token if `session.modified = True`. A simple fix would be to also check if the session data is empty.


Discussion:

Resolving patch:
diff --git a/allauth/headless/internal/sessionkit.py b/allauth/headless/internal/sessionkit.py
--- a/allauth/headless/internal/sessionkit.py
+++ b/allauth/headless/internal/sessionkit.py
@@ -21,7 +21,8 @@ def expose_session_token(request):
     strategy = app_settings.TOKEN_STRATEGY
     hdr_token = strategy.get_session_token(request)
     modified = request.session.modified
-    if modified:
+    empty = request.session.is_empty()
+    if modified and not empty:
         new_token = strategy.create_session_token(request)
         if not hdr_token or hdr_token != new_token:
             return new_token


Test patch:
diff --git a/allauth/headless/account/tests/test_session.py b/allauth/headless/account/tests/test_session.py
--- a/allauth/headless/account/tests/test_session.py
+++ b/allauth/headless/account/tests/test_session.py
@@ -21,4 +21,13 @@ def test_logout(auth_client, headless_reverse):
     resp = auth_client.delete(headless_reverse("headless:account:current_session"))
     assert resp.status_code == 401
     resp = auth_client.get(headless_reverse("headless:account:current_session"))
+    assert resp.status_code in [401, 410]
+
+
+def test_logout_no_token(app_client, user):
+    app_client.force_login(user)
+    resp = app_client.get(reverse("headless:app:account:current_session"))
+    assert resp.status_code == 200
+    resp = app_client.delete(reverse("headless:app:account:current_session"))
     assert resp.status_code == 401
+    assert "session_token" not in resp.json()["meta"]
Repository: kymatio/kymatio

Issue:
[MAINT] AttributeError: module 'kymatio' has no attribute '__version__'
This came up in #172

PEP 396 has introduced the convention of exposing the constant `__version__` to the top-level module
At the moment this is in `kymatio.version.version` (so that `version.py` can be loaded in `setup.py` without importing the whole `kymatio` module)
https://www.python.org/dev/peps/pep-0396/

Will submit a PR later



Discussion:

Resolving patch:
diff --git a/kymatio/__init__.py b/kymatio/__init__.py
--- a/kymatio/__init__.py
+++ b/kymatio/__init__.py
@@ -1,13 +1,3 @@
-__all__ = [
-            'Scattering3D',
-            'Scattering2D',
-            'Scattering1D'
-            ]
-
-from .scattering2d.scattering2d import Scattering2D
-from .scattering1d.scattering1d import Scattering1D
-from .scattering3d.scattering3d import Scattering3D
-
 # Make sure that DeprecationWarning within this package always gets printed
 ### Snippet copied from sklearn.__init__
 import warnings
@@ -16,4 +6,14 @@
                         module=r'^{0}.*'.format(re.escape(__name__)))
 ### End Snippet
 
+__all__ = [
+            'Scattering1D',
+            'Scattering2D',
+            'Scattering3D'
+            ]
+
+from .scattering1d.scattering1d import Scattering1D
+from .scattering2d.scattering2d import Scattering2D
+from .scattering3d.scattering3d import Scattering3D
 
+from .version import version as __version__


Test patch:
Repository: kymatio/kymatio

Issue:
Warning in `mnist.py`
Specifically, https://github.com/kymatio/kymatio/blob/289bc26551e92456ef7a48fbe83d48e157f7632c/examples/2d/mnist.py#L50 generates a warning saying that `size_average` will be deprecated and says to use `reduction='sum'` instead. Is this ok for us to do?


Discussion:

Resolving patch:
diff --git a/examples/2d/mnist.py b/examples/2d/mnist.py
--- a/examples/2d/mnist.py
+++ b/examples/2d/mnist.py
@@ -47,7 +47,7 @@ def test(model, device, test_loader, scattering):
         for data, target in test_loader:
             data, target = data.to(device), target.to(device)
             output = model(scattering(data))
-            test_loss += F.cross_entropy(output, target, size_average=False).item() # sum up batch loss
+            test_loss += F.cross_entropy(output, target, reduction='sum').item() # sum up batch loss
             pred = output.max(1, keepdim=True)[1] # get the index of the max log-probability
             correct += pred.eq(target.view_as(pred)).sum().item()
 


Test patch:
Repository: kymatio/kymatio

Issue:
[BUG] unimported warnings in cdgmm3d
The warnings for non-contiguous inputs in the PyTorch backend of `cdgmm3d` need to be prefaced by an `import warnings` statement

https://github.com/kymatio/kymatio/blob/master/kymatio/scattering3d/backend/backend_torch.py#L69

https://github.com/kymatio/kymatio/blob/master/kymatio/scattering3d/backend/backend_torch.py#L72

Besides, the error messages should not end with exclamation marks. They add insult to injury.

tagging @louity


Discussion:

Resolving patch:
diff --git a/kymatio/scattering1d/scattering1d.py b/kymatio/scattering1d/scattering1d.py
--- a/kymatio/scattering1d/scattering1d.py
+++ b/kymatio/scattering1d/scattering1d.py
@@ -5,7 +5,6 @@
 import numpy as np
 import math
 
-import warnings
 
 from .backend import pad, unpad, real, subsample_fourier, modulus_complex, fft1d_c2c, ifft1d_c2c
 from .utils import compute_padding, compute_border_indices
diff --git a/kymatio/scattering2d/scattering2d.py b/kymatio/scattering2d/scattering2d.py
--- a/kymatio/scattering2d/scattering2d.py
+++ b/kymatio/scattering2d/scattering2d.py
@@ -4,7 +4,6 @@
 
 __all__ = ['Scattering']
 
-import warnings
 import torch
 from .backend import cdgmm, Modulus, SubsampleFourier, fft, Pad, unpad
 from .filter_bank import filter_bank
diff --git a/kymatio/scattering3d/backend/backend_torch.py b/kymatio/scattering3d/backend/backend_torch.py
--- a/kymatio/scattering3d/backend/backend_torch.py
+++ b/kymatio/scattering3d/backend/backend_torch.py
@@ -1,6 +1,5 @@
-from collections import defaultdict
 import torch
-import numpy as np
+import warnings
 
 NAME = 'torch'
 


Test patch:
Repository: kymatio/kymatio

Issue:
[BUG] __all__ in scattering2d.py
another bug I found while eyeballing at pyflakes

https://github.com/kymatio/kymatio/blob/master/kymatio/scattering2d/scattering2d.py#L5

`Scattering` should read as `Scattering2D`

this affects the behavior of `from kymatio.scattering2d import *`

EDIT: the reason why it does work as expected is that it gets overwritten by `__init__.py` in the module. Still, it would be good to clarify the situation

tagging @eugenium 


Discussion:

Resolving patch:
diff --git a/kymatio/scattering1d/scattering1d.py b/kymatio/scattering1d/scattering1d.py
--- a/kymatio/scattering1d/scattering1d.py
+++ b/kymatio/scattering1d/scattering1d.py
@@ -7,6 +7,8 @@
 
 import warnings
 
+__all__ = ['Scattering1D']
+
 from .backend import pad, unpad, real, subsample_fourier, modulus_complex, fft1d_c2c, ifft1d_c2c
 from .utils import compute_padding, compute_border_indices
 from .utils import cast_psi, cast_phi
diff --git a/kymatio/scattering2d/scattering2d.py b/kymatio/scattering2d/scattering2d.py
--- a/kymatio/scattering2d/scattering2d.py
+++ b/kymatio/scattering2d/scattering2d.py
@@ -2,7 +2,7 @@
 # Scientific Ancestry: Edouard Oyallon, Laurent Sifre, Joan Bruna
 
 
-__all__ = ['Scattering']
+__all__ = ['Scattering2D']
 
 import warnings
 import torch


Test patch:
Repository: kymatio/kymatio

Issue:
[DOC] solving Sphinx issues
W.r.t.:
Issues: #97  #110 #135 #105 #106 #108 #111 
PR: #144

We must find a way to remove the list of "ignore-patterns" here:

https://github.com/eickenberg/kymatio/blob/master/doc/source/conf.py#L61 

At the moment we do this, and that the sphinx works, then we will be good with the gallery!


Discussion:

Resolving patch:
diff --git a/doc/source/conf.py b/doc/source/conf.py
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -58,7 +58,7 @@
     # path where to save gallery generated examples
     'gallery_dirs': ['gallery_1d','gallery_2d','gallery_3d'],
     'ignore_pattern':
-    '__init__.py|mnist.py|scattering3d_qm7.py',
+    '__init__.py',
 }
 
 intersphinx_mapping = {'kymatio': ('../kymatio', None)}
diff --git a/examples/3d/scattering3d_qm7.py b/examples/3d/scattering3d_qm7.py
--- a/examples/3d/scattering3d_qm7.py
+++ b/examples/3d/scattering3d_qm7.py
@@ -1,3 +1,9 @@
+"""
+3D scattering quantum chemistry regression
+==========================================
+This uses the 3D scattering on a standard dataset.
+"""
+
 import numpy as np
 import time
 import torch


Test patch: