Skip to content

Commit

Permalink
fix(isort): Unbreak CI by upgrading isort
Browse files Browse the repository at this point in the history
Migrate isort configuration, highlights:
- Remove future library that is now strictly matched (__future__) and
  the default.
- Sections is still needed, cause we have known_django
- create a tox environment that will fix issues according to isort's
  wishes
- Apply changes resulting from the previous
  • Loading branch information
vylmen authored and pennersr committed Aug 11, 2020
1 parent c19a212 commit 97abe3e
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 18 deletions.
4 changes: 1 addition & 3 deletions .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ include_trailing_comma=1
multi_line_output=3
lines_after_imports=2
known_django=django
known_future_library=future
known_standard_library=types,requests
extra_standard_library=types,requests
known_first_party=allauth
default_section=THIRDPARTY
sections=FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
9 changes: 5 additions & 4 deletions allauth/account/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def populate_username(self, request, user):
username is already present it is assumed to be valid
(unique).
"""
from .utils import user_username, user_email, user_field
from .utils import user_email, user_field, user_username
first_name = user_field(user, 'first_name')
last_name = user_field(user, 'last_name')
email = user_email(user)
Expand All @@ -219,7 +219,7 @@ def save_user(self, request, user, form, commit=True):
Saves a new `User` instance using information provided in the
signup form.
"""
from .utils import user_username, user_email, user_field
from .utils import user_email, user_field, user_username

data = form.cleaned_data
first_name = data.get('first_name')
Expand Down Expand Up @@ -415,8 +415,9 @@ def is_safe_url(self, url):
try:
from django.utils.http import url_has_allowed_host_and_scheme
except ImportError:
from django.utils.http import \
is_safe_url as url_has_allowed_host_and_scheme
from django.utils.http import (
is_safe_url as url_has_allowed_host_and_scheme,
)

return url_has_allowed_host_and_scheme(url, allowed_hosts=None)

Expand Down
4 changes: 2 additions & 2 deletions allauth/account/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ def PRESERVE_USERNAME_CASING(self):
@property
def USERNAME_VALIDATORS(self):
from django.core.exceptions import ImproperlyConfigured
from allauth.utils import import_attribute
from allauth.utils import get_user_model

from allauth.utils import get_user_model, import_attribute

path = self._setting('USERNAME_VALIDATORS', None)
if path:
Expand Down
2 changes: 1 addition & 1 deletion allauth/socialaccount/providers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def sociallogin_from_response(self, request, response):
:return: A populated instance of the `SocialLogin` model (unsaved).
"""
# NOTE: Avoid loading models at top due to registry boot...
from allauth.socialaccount.models import SocialLogin, SocialAccount
from allauth.socialaccount.models import SocialAccount, SocialLogin

adapter = get_adapter(request)
uid = self.extract_uid(response)
Expand Down
5 changes: 3 additions & 2 deletions allauth/socialaccount/providers/google/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ def get_mocked_response(self,
(repr(verified_email).lower())))

def test_google_compelete_login_401(self):
from allauth.socialaccount.providers.google.views import \
GoogleOAuth2Adapter
from allauth.socialaccount.providers.google.views import (
GoogleOAuth2Adapter,
)

class LessMockedResponse(MockedResponse):
def raise_for_status(self):
Expand Down
5 changes: 3 additions & 2 deletions allauth/socialaccount/providers/ynab/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ def get_mocked_response(self):
""")

def test_ynab_compelete_login_401(self):
from allauth.socialaccount.providers.ynab.views import \
YNABOAuth2Adapter
from allauth.socialaccount.providers.ynab.views import (
YNABOAuth2Adapter,
)

class LessMockedResponse(MockedResponse):
def raise_for_status(self):
Expand Down
5 changes: 3 additions & 2 deletions allauth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,11 @@ def generate_username_candidates(basename):


def generate_unique_username(txts, regex=None):
from .account.app_settings import USER_MODEL_USERNAME_FIELD
from .account.adapter import get_adapter
from allauth.account.utils import filter_users_by_username

from .account.adapter import get_adapter
from .account.app_settings import USER_MODEL_USERNAME_FIELD

adapter = get_adapter()
basename = _generate_unique_username_base(txts, regex)
candidates = generate_username_candidates(basename)
Expand Down
11 changes: 9 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ setenv =
PYTHONWARNINGS = all
deps =
coverage
py27: mock >= 1.0.1
django20: Django==2.0.*
django21: Django==2.1.*
django22: Django==2.2.*
Expand All @@ -41,7 +40,15 @@ deps =
isort
commands =
flake8 {posargs:{toxinidir}/allauth}
isort --check-only --skip-glob '*/migrations/*' --recursive --diff {posargs:{toxinidir}/allauth}
isort --check-only --skip-glob '*/migrations/*' --diff {posargs:{toxinidir}/allauth}

[testenv:isort]
basepython = python3.7
skip_install = True
deps =
isort >5
commands =
isort --skip-glob '*/migrations/*' {posargs:{toxinidir}/allauth}

[testenv:standardjs]
skip_install = True
Expand Down

0 comments on commit 97abe3e

Please sign in to comment.