<commit_before>"""Views for MailChimp API v3."""
import requests

from allauth.socialaccount.providers.oauth2.views import (OAuth2Adapter,
                                                          OAuth2LoginView,
                                                          OAuth2CallbackView)

from .provider import MailChimpProvider


class MailChimpOAuth2Adapter(OAuth2Adapter):

    """OAuth2Adapter for MailChimp API v3."""

    provider_id = MailChimpProvider.id

    access_token_url = 'https://login.mailchimp.com/oauth2/token'
    authorize_url = 'https://login.mailchimp.com/oauth2/authorize'
    profile_url = 'https://login.mailchimp.com/oauth2/metadata'

    def complete_login(self, request, app, token, **kwargs):
        """Complete login, ensuring correct OAuth header."""
        headers = {'Authorization': 'OAuth {0}'.format(token.token)}
        metadata = requests.get(self.profile_url, headers=headers)
        extra_data = metadata.json()
        return self.get_provider().sociallogin_from_response(request,
                                                             extra_data)


oauth2_login = OAuth2LoginView.adapter_view(MailChimpOAuth2Adapter)
oauth2_callback = OAuth2CallbackView.adapter_view(MailChimpOAuth2Adapter)<commit_msg>Tweak mailchimp views.py to conform to isort.<commit_after>"""Views for MailChimp API v3."""
import requests

from allauth.socialaccount.providers.oauth2.views import (
    OAuth2Adapter,
    OAuth2CallbackView,
    OAuth2LoginView,
)

from .provider import MailChimpProvider


class MailChimpOAuth2Adapter(OAuth2Adapter):

    """OAuth2Adapter for MailChimp API v3."""

    provider_id = MailChimpProvider.id

    access_token_url = 'https://login.mailchimp.com/oauth2/token'
    authorize_url = 'https://login.mailchimp.com/oauth2/authorize'
    profile_url = 'https://login.mailchimp.com/oauth2/metadata'

    def complete_login(self, request, app, token, **kwargs):
        """Complete login, ensuring correct OAuth header."""
        headers = {'Authorization': 'OAuth {0}'.format(token.token)}
        metadata = requests.get(self.profile_url, headers=headers)
        extra_data = metadata.json()
        return self.get_provider().sociallogin_from_response(request,
                                                             extra_data)


oauth2_login = OAuth2LoginView.adapter_view(MailChimpOAuth2Adapter)
oauth2_callback = OAuth2CallbackView.adapter_view(MailChimpOAuth2Adapter)
{'fraction_non_alphanumeric': 0.09759085340955492, 'fraction_numerical': 0.01551653736218865, 'mean_word_length': 2.9708265802269045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3864788', 'n_tokens_mistral': 711, 'n_tokens_neox': 693, 'n_words': 125}