Skip to content

Commit

Permalink
Add isort as a companion to black (#5132)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstufft authored Nov 28, 2018
1 parent 7c31754 commit 1fbb4ac
Show file tree
Hide file tree
Showing 184 changed files with 269 additions and 294 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,13 @@ tests:


reformat: .state/env/pyvenv.cfg
$(BINDIR)/isort -rc warehouse/ tests/
$(BINDIR)/black warehouse/ tests/

lint: .state/env/pyvenv.cfg
$(BINDIR)/flake8 .
$(BINDIR)/black --check warehouse/ tests/
$(BINDIR)/isort -rc -c warehouse/ tests/
$(BINDIR)/doc8 --allow-long-titles README.rst CONTRIBUTING.rst docs/ --ignore-path docs/_build/
# TODO: Figure out a solution to https://github.com/deezer/template-remover/issues/1
# so we can remove extra_whitespace from below.
Expand Down
1 change: 1 addition & 0 deletions requirements/lint.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ flake8
html-linter
pep8-naming
black==18.9b0
isort
4 changes: 4 additions & 0 deletions requirements/lint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ flake8==3.6.0 \
--hash=sha256:c01f8a3963b3571a8e6bd7a4063359aff90749e160778e03817cd9b71c9e07d2
html-linter==0.4.0 \
--hash=sha256:342dad677f2fc810a2562fde0959046ed0d8fa1387bd9e085869e908c1941191
isort==4.3.4 \
--hash=sha256:1153601da39a25b14ddc54955dbbacbb6b2d19135386699e2ad58517953b34af \
--hash=sha256:b9c40e9750f3d77e6e4d441d8b0266cf555e7cdabdcff33c4fd06366ca761ef8 \
--hash=sha256:ec9ef8f4a9bc6f71eec99e1806bfa2de401650d996c59330782b89a5555c1497
mccabe==0.6.1 \
--hash=sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42 \
--hash=sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f
Expand Down
11 changes: 11 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ exclude = *.egg,*/interfaces.py,node_modules,.state
ignore = W503,E203
select = E,W,F,N

[isort]
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=88
lines_between_types=1
combine_as_imports=True
default_section=THIRDPARTY
known_first_party=warehouse,tests

[tool:pytest]
norecursedirs = build dist node_modules *.egg-info .state requirements
markers =
Expand Down
4 changes: 2 additions & 2 deletions tests/common/db/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import factory
import factory.fuzzy

from warehouse.accounts.models import User, Email
from warehouse.accounts.models import Email, User

from .base import WarehouseFactory, FuzzyEmail
from .base import FuzzyEmail, WarehouseFactory


class UserFactory(WarehouseFactory):
Expand Down
2 changes: 1 addition & 1 deletion tests/common/db/ses.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from warehouse.email.ses.models import EmailMessage, Event, EventTypes

from .base import WarehouseFactory, FuzzyEmail
from .base import FuzzyEmail, WarehouseFactory


class EmailMessageFactory(WarehouseFactory):
Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

import os
import os.path
from unittest import mock
import xmlrpc.client

from contextlib import contextmanager
from unittest import mock

import alembic.command
import click.testing
Expand All @@ -26,13 +26,13 @@

from pyramid.static import ManifestCacheBuster
from pytest_postgresql.factories import (
init_postgresql_database,
drop_postgresql_database,
get_config,
init_postgresql_database,
)
from sqlalchemy import event

from warehouse import config, admin, static
from warehouse import admin, config, static
from warehouse.accounts import services
from warehouse.metrics import IMetricsService

Expand Down
4 changes: 3 additions & 1 deletion tests/functional/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
# limitations under the License.

import os
import warehouse

from jinja2 import Environment, FileSystemLoader

import warehouse


def test_templates_for_empty_titles():
"""
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/accounts/test_auth_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pretend
import uuid

import pretend

from pyramid import authentication
from pyramid.interfaces import IAuthenticationPolicy
from zope.interface.verify import verifyClass
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/accounts/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@

from warehouse import accounts
from warehouse.accounts.interfaces import (
IUserService,
ITokenService,
IPasswordBreachedService,
ITokenService,
IUserService,
)
from warehouse.accounts.models import DisableReason
from warehouse.accounts.services import (
TokenServiceFactory,
HaveIBeenPwnedPasswordBreachedService,
TokenServiceFactory,
database_login_factory,
)
from warehouse.accounts.models import DisableReason
from warehouse.errors import BasicAuthBreachedPassword
from warehouse.rate_limiting import RateLimit, IRateLimiter
from warehouse.rate_limiting import IRateLimiter, RateLimit


class TestLogin:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/accounts/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from warehouse.accounts.models import User, UserFactory

from ...common.db.accounts import (
UserFactory as DBUserFactory,
EmailFactory as DBEmailFactory,
UserFactory as DBUserFactory,
)


Expand Down
6 changes: 3 additions & 3 deletions tests/unit/accounts/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

from warehouse.accounts import services
from warehouse.accounts.interfaces import (
IUserService,
ITokenService,
IPasswordBreachedService,
ITokenService,
IUserService,
TokenExpired,
TokenInvalid,
TokenMissing,
Expand All @@ -35,7 +35,7 @@
from warehouse.metrics import IMetricsService, NullMetrics
from warehouse.rate_limiting.interfaces import IRateLimiter

from ...common.db.accounts import UserFactory, EmailFactory
from ...common.db.accounts import EmailFactory, UserFactory


class TestDatabaseUserService:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/accounts/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

from warehouse.accounts import views
from warehouse.accounts.interfaces import (
IUserService,
ITokenService,
IPasswordBreachedService,
ITokenService,
IUserService,
TokenExpired,
TokenInvalid,
TokenMissing,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/admin/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

import pretend

from warehouse.accounts import views as accounts_views
from warehouse import admin
from warehouse.accounts import views as accounts_views


def test_includeme(mock_manifest_cache_buster, monkeypatch):
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/admin/views/test_blacklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

from ....common.db.accounts import UserFactory
from ....common.db.packaging import (
BlacklistedProjectFactory,
FileFactory,
ProjectFactory,
ReleaseFactory,
RoleFactory,
FileFactory,
BlacklistedProjectFactory,
)


Expand Down
4 changes: 2 additions & 2 deletions tests/unit/admin/views/test_emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

import uuid

import pytest
import pretend
import pytest

from pyramid.httpexceptions import HTTPNotFound, HTTPBadRequest
from pyramid.httpexceptions import HTTPBadRequest, HTTPNotFound

from warehouse.admin.views import emails as views

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/admin/views/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
# limitations under the License.

import datetime
import uuid

import pretend
import pytest
import uuid

from pyramid.httpexceptions import HTTPBadRequest, HTTPMovedPermanently, HTTPSeeOther

Expand Down
5 changes: 3 additions & 2 deletions tests/unit/admin/views/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import uuid

import pretend
import pytest
import uuid

from pyramid.httpexceptions import HTTPBadRequest, HTTPNotFound
from webob.multidict import MultiDict, NoVars

from warehouse.admin.views import users as views
from warehouse.packaging.models import Project

from ....common.db.accounts import User, UserFactory, EmailFactory
from ....common.db.accounts import EmailFactory, User, UserFactory
from ....common.db.packaging import JournalEntryFactory, ProjectFactory, RoleFactory


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/email/ses/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
from warehouse.accounts.models import UnverifyReasons
from warehouse.email.ses.models import (
MAX_TRANSIENT_BOUNCES,
EmailMessage,
EmailStatus,
EmailStatuses,
EmailMessage,
)

from ....common.db.accounts import EmailFactory
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/email/ses/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import datetime

from warehouse.email.ses.models import EmailMessage
from warehouse.email.ses.tasks import CLEANUP_DELIVERED_AFTER, CLEANUP_AFTER, cleanup
from warehouse.email.ses.tasks import CLEANUP_AFTER, CLEANUP_DELIVERED_AFTER, cleanup

from ....common.db.ses import EmailMessageFactory

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/email/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from warehouse.email.interfaces import IEmailSender
from warehouse.email.services import (
EmailMessage,
SMTPEmailSender,
SESEmailSender,
SMTPEmailSender,
_format_sender,
)
from warehouse.email.ses.models import EmailMessage as SESEmailMessage
Expand Down
14 changes: 7 additions & 7 deletions tests/unit/forklift/test_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,28 @@
from wtforms.form import Form
from wtforms.validators import ValidationError

from warehouse.admin.flags import AdminFlag
from warehouse.admin.squats import Squat
from warehouse.classifiers.models import Classifier
from warehouse.forklift import legacy
from warehouse.packaging.interfaces import IFileStorage
from warehouse.packaging.models import (
File,
Filename,
Dependency,
DependencyKind,
Release,
File,
Filename,
JournalEntry,
Project,
Release,
Role,
JournalEntry,
)
from warehouse.admin.flags import AdminFlag

from ...common.db.accounts import UserFactory, EmailFactory
from ...common.db.accounts import EmailFactory, UserFactory
from ...common.db.classifiers import ClassifierFactory
from ...common.db.packaging import (
FileFactory,
ProjectFactory,
ReleaseFactory,
FileFactory,
RoleFactory,
)

Expand Down
3 changes: 2 additions & 1 deletion tests/unit/i18n/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import email.utils

import babel.dates
import babel.numbers
import email.utils
import pretend

from warehouse.i18n import filters
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/legacy/api/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

from ....common.db.accounts import UserFactory
from ....common.db.packaging import (
ProjectFactory,
ReleaseFactory,
FileFactory,
JournalEntryFactory,
ProjectFactory,
ReleaseFactory,
)


Expand Down
4 changes: 2 additions & 2 deletions tests/unit/legacy/api/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

from ....common.db.accounts import UserFactory
from ....common.db.packaging import (
ProjectFactory,
ReleaseFactory,
FileFactory,
JournalEntryFactory,
ProjectFactory,
ReleaseFactory,
)


Expand Down
7 changes: 4 additions & 3 deletions tests/unit/legacy/api/xmlrpc/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@
# limitations under the License.

import celery
import redis
import pretend
import pytest
import redis

from pyramid.exceptions import ConfigurationError

import warehouse.legacy.api.xmlrpc.cache
from warehouse.legacy.api.xmlrpc.cache import services

from warehouse.legacy.api.xmlrpc import cache
from warehouse.legacy.api.xmlrpc.cache import (
cached_return_view,
NullXMLRPCCache,
RedisLru,
RedisXMLRPCCache,
cached_return_view,
services,
)
from warehouse.legacy.api.xmlrpc.cache.interfaces import CacheError, IXMLRPCCache

Expand Down
Loading

0 comments on commit 1fbb4ac

Please sign in to comment.