Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort imports based on flake8-import-order #572

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .flake8

This file was deleted.

7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,10 @@ twine.registered_commands =
register = twine.commands.register:main
console_scripts =
twine = twine.__main__:main

[flake8]
# Must be in setup.cfg due to https://github.com/sqlalchemyorg/zimports/issues/10
# Matching black's default
max-line-length = 88
import-order-style = google
application-import-names = twine,helpers
16 changes: 8 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import contextlib
import textwrap
import secrets
import subprocess
import pathlib
import datetime
import functools
import getpass
import pathlib
import secrets
import subprocess
import sys
import datetime
import textwrap

import pytest
import portend
import requests
import jaraco.envs
import munch
import portend
import pytest
import requests

from twine import settings

Expand Down
6 changes: 1 addition & 5 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import pytest

from twine import (
auth,
exceptions,
utils,
)
from twine import auth, exceptions, utils


cred = auth.CredentialInput
Expand Down
2 changes: 1 addition & 1 deletion tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest

from twine.commands import _find_dists, _group_wheel_files_first
from twine import exceptions
from twine.commands import _find_dists, _group_wheel_files_first


def test_ensure_wheel_files_uploaded_first():
Expand Down
4 changes: 2 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pretend

from twine import __main__ as dunder_main
from twine import exceptions

import pretend


def test_exception_handling(monkeypatch):
replaced_dispatch = pretend.raiser(exceptions.InvalidConfiguration("foo"))
Expand Down
4 changes: 2 additions & 2 deletions tests/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from twine import package, exceptions

import pretend
import pytest

from twine import exceptions, package


def test_sign_file(monkeypatch):
replaced_check_call = pretend.call_recorder(lambda args: None)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_register.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from __future__ import unicode_literals

import pytest
import pretend
import pytest

from twine.commands import register
from twine import exceptions
from twine.commands import register


# TODO: Copied from test_upload.py. Extract to helpers?
Expand Down
8 changes: 4 additions & 4 deletions tests/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from contextlib import contextmanager

import pretend
import pytest
import requests

from twine import repository
from twine.utils import DEFAULT_REPOSITORY, TEST_REPOSITORY

import pretend
import pytest
from contextlib import contextmanager


def test_gpg_signature_structure_is_preserved():
data = {
Expand Down
6 changes: 3 additions & 3 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import os.path
import textwrap
import argparse

import pytest

from twine import exceptions
from twine import settings

import pytest


def test_settings_takes_no_positional_arguments():
"""Verify that the Settings initialization is kw-only."""
Expand Down
7 changes: 3 additions & 4 deletions tests/test_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
import pytest
from requests.exceptions import HTTPError

from twine.commands import upload
from twine import package, cli, exceptions
import twine

import helpers
import twine
from twine import cli, exceptions, package
from twine.commands import upload

SDIST_FIXTURE = "tests/fixtures/twine-1.5.0.tar.gz"
WHEEL_FIXTURE = "tests/fixtures/twine-1.5.0-py2.py3-none-any.whl"
Expand Down
5 changes: 2 additions & 3 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
import os.path
import textwrap

import pytest
import pretend

from twine import exceptions, utils
import pytest

import helpers
from twine import exceptions, utils


def test_get_config(tmpdir):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from twine import wheel

import pytest

from twine import wheel


@pytest.fixture(
params=[
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ commands =
deps =
black
flake8
flake8-import-order
commands =
black --check --diff twine/ tests/
flake8 twine/ tests/
Expand Down
8 changes: 4 additions & 4 deletions twine/auth.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import warnings
import getpass
import functools
from typing import Optional, Callable
import getpass
from typing import Callable, Optional
import warnings

import keyring

from . import utils
from . import exceptions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We seem to have a mixture of absolute imports from twine import ... and absolute-relative imports from . import ... we should probably standardize on those

Copy link
Contributor Author

@bhrutledge bhrutledge Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to address this after we settle on one of these PRs.

from . import utils


class CredentialInput:
Expand Down
8 changes: 4 additions & 4 deletions twine/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse
import pkg_resources
import setuptools

import tqdm
import pkg_resources
import pkginfo
import requests
import requests_toolbelt
import pkginfo
import setuptools
import tqdm

import twine
from twine._installed import Installed
Expand Down
3 changes: 1 addition & 2 deletions twine/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import List

import glob
import os.path
from typing import List

from twine import exceptions

Expand Down
2 changes: 1 addition & 1 deletion twine/commands/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.
import argparse
import cgi
from io import StringIO
import re
import sys
from io import StringIO

import readme_renderer.rst

Expand Down
2 changes: 1 addition & 1 deletion twine/commands/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import argparse
import os.path

from twine.package import PackageFile
from twine import exceptions
from twine import settings
from twine.package import PackageFile


def register(register_settings, package):
Expand Down
4 changes: 2 additions & 2 deletions twine/commands/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import argparse
import os.path

from twine.commands import _find_dists
from twine.package import PackageFile
from twine import exceptions
from twine import settings
from twine import utils
from twine.commands import _find_dists
from twine.package import PackageFile


def skip_upload(response, skip_existing, package):
Expand Down
9 changes: 4 additions & 5 deletions twine/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,20 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Dict, IO, Optional, Union, Sequence, Tuple

import collections
import hashlib
from hashlib import blake2b
import io
import os
import subprocess
from hashlib import blake2b
from typing import Dict, IO, Optional, Sequence, Tuple, Union

import pkginfo
import pkg_resources
import pkginfo

from twine import exceptions
from twine.wheel import Wheel
from twine.wininst import WinInst
from twine import exceptions

DIST_TYPES = {
"bdist_wheel": Wheel,
Expand Down
7 changes: 3 additions & 4 deletions twine/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Dict, List, Optional, Tuple
import sys

from tqdm import tqdm
from typing import Dict, List, Optional, Tuple

import requests
from requests import codes
Expand All @@ -23,9 +21,10 @@
from requests.packages.urllib3 import util
from requests_toolbelt.multipart import MultipartEncoder, MultipartEncoderMonitor
from requests_toolbelt.utils import user_agent
from tqdm import tqdm

from twine.package import PackageFile, MetadataValue
import twine
from twine.package import MetadataValue, PackageFile

KEYWORDS_TO_NOT_FLATTEN = {"gpg_signature", "content"}

Expand Down
5 changes: 2 additions & 3 deletions twine/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import cast, Optional

import argparse
from typing import cast, Optional

from twine import auth
from twine import exceptions
from twine import repository
from twine import utils
from twine import auth


class Settings:
Expand Down
9 changes: 4 additions & 5 deletions twine/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Callable, DefaultDict, Dict, Optional

import os
import os.path
import functools
import argparse
import collections
import configparser
import functools
import os
import os.path
from typing import Callable, DefaultDict, Dict, Optional
from urllib.parse import urlparse, urlunparse

import requests
Expand Down
2 changes: 1 addition & 1 deletion twine/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from io import StringIO
import os
import re
import zipfile
from io import StringIO

from pkginfo import distribution
from pkginfo.distribution import Distribution
Expand Down