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

Add isort #1120

Merged
merged 2 commits into from
Mar 9, 2022
Merged
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
10 changes: 6 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ jobs:
- name: Run tests
run: python -m pytest -v --timeout=1800 --durations=20 test

flake8-formatting:
name: code linting with flake8
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install dependencies
run: pip install flake8
run: python -m pip install flake8 isort

- name: Check code with flake8
- name: flake8
run: flake8 .

- name: isort
run: isort --check-only .
1 change: 1 addition & 0 deletions asv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import sys

# This __version__ assignment is parsed by setup.py; keep it in this form.
# Development versions end with ".dev" (suffix is added below).
__version__ = "0.6.dev"
Expand Down
8 changes: 6 additions & 2 deletions asv/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,28 @@
# there although it's not part of the package, and Python puts it to
# sys.path[0] on start which can shadow other modules
import sys

if __name__ == "__main__":
_old_sys_path_head = sys.path.pop(0)
else:
_old_sys_path_head = None

import copy

try:
import cProfile as profile
except ImportError:
profile = None
import ctypes
import errno
from ctypes.util import find_library
from hashlib import sha256
import errno

if sys.version_info[0] >= 3:
import importlib.machinery
else:
import imp

import inspect
import itertools
import json
Expand All @@ -68,7 +72,6 @@
from importlib import import_module
from collections import Counter


# The best timer we can use is time.process_time, but it is not
# available in the Python stdlib until Python 3.3. This is a ctypes
# backport for Pythons that don't have it.
Expand Down Expand Up @@ -1346,6 +1349,7 @@ def main_run_server(args):

def main_timing(argv):
import argparse

import asv.statistics
import asv.util
import asv.console
Expand Down
4 changes: 2 additions & 2 deletions asv/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import re
import tempfile
import itertools

from .console import log
from . import util
from . import runner
from . import util, runner
from .repo import NoSuchNameError


Expand Down
4 changes: 1 addition & 3 deletions asv/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

import argparse
import sys
from .. import config
from .. import util

from .. import config, util
from . import common_args


# This list is ordered in order of average workflow
command_order = [
'Quickstart',
Expand Down
4 changes: 1 addition & 3 deletions asv/commands/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst

from ..benchmarks import Benchmarks
from . import Command
from . import Command, common_args
from ..repo import get_repo

from . import common_args
from .. import environment


Expand Down
3 changes: 1 addition & 2 deletions asv/commands/common_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import multiprocessing
import argparse

from .. import __version__
from .. import util
from .. import __version__, util


def add_global_arguments(parser, suppress_defaults=True):
Expand Down
7 changes: 2 additions & 5 deletions asv/commands/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

import itertools

from . import Command
from . import Command, common_args
from ..benchmarks import Benchmarks
from ..machine import iter_machine_files
from ..results import iter_results_for_machine_and_hash
from ..repo import get_repo, NoSuchNameError
from ..util import human_value, load_json
from ..console import log, color_print
from ..environment import get_environments
from .. import util
from .. import statistics

from . import common_args
from .. import util, statistics


def mean(values):
Expand Down
8 changes: 2 additions & 6 deletions asv/commands/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
import os
import argparse

from . import Command
from . import Command, common_args
from .run import Run
from .compare import Compare

from ..repo import get_repo, NoSuchNameError
from ..console import color_print, log
from .. import results
from .. import util

from . import common_args
from .. import results, util


class Continuous(Command):
Expand Down
5 changes: 1 addition & 4 deletions asv/commands/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

import math

from . import Command
from . import Command, common_args
from ..benchmarks import Benchmarks
from ..console import log
from ..machine import Machine
from ..repo import get_repo
from ..runner import run_benchmarks
from .. import util

from .setup import Setup

from . import common_args


def draw_graph(lo, mid, hi, total):
nchars = 60
Expand Down
1 change: 0 additions & 1 deletion asv/commands/machine.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst

from . import Command

from .. import machine


Expand Down
1 change: 0 additions & 1 deletion asv/commands/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import socket

from . import Command

from ..console import log
from .. import util

Expand Down
4 changes: 1 addition & 3 deletions asv/commands/profiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import sys
import tempfile

from . import Command
from . import Command, common_args
from ..benchmarks import Benchmarks
from ..console import log, color_print
from ..environment import get_environments, is_existing_only
Expand All @@ -19,8 +19,6 @@
from ..util import hash_equal, iter_subclasses
from .. import util

from . import common_args


@contextlib.contextmanager
def temp_profile(profile_data):
Expand Down
4 changes: 1 addition & 3 deletions asv/commands/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
from ..repo import get_repo
from ..results import iter_results
from ..publishing import OutputPublisher
from .. import statistics
from .. import util
from .. import __version__
from .. import statistics, util, __version__


def check_benchmark_params(name, benchmark):
Expand Down
5 changes: 2 additions & 3 deletions asv/commands/rm.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from fnmatch import fnmatchcase
import sys
from fnmatch import fnmatchcase

from . import Command
from . import Command, util
from .. import console
from ..console import log
from ..results import iter_results
from . import util


class Rm(Command):
Expand Down
12 changes: 3 additions & 9 deletions asv/commands/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,19 @@
import time
import argparse
import textwrap

from collections import defaultdict

from . import Command
from . import Command, common_args
from ..benchmarks import Benchmarks
from ..console import log
from ..machine import Machine
from ..repo import get_repo, NoSuchNameError
from ..results import (Results, get_existing_hashes,
iter_results_for_machine_and_hash)
from ..results import Results, get_existing_hashes, iter_results_for_machine_and_hash
from ..runner import run_benchmarks, skip_benchmarks
from .. import environment
from .. import util

from .. import environment, util
from .setup import Setup
from .show import Show

from . import common_args


def _do_build(args):
env, conf, repo, commit_hash = args
Expand Down
7 changes: 2 additions & 5 deletions asv/commands/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
import traceback
from collections import defaultdict

from . import Command
from . import Command, common_args
from ..console import log
from .. import environment
from .. import util

from . import common_args
from .. import environment, util


def _create(env):
Expand Down
4 changes: 1 addition & 3 deletions asv/commands/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from collections import defaultdict

from . import Command
from . import Command, common_args
from ..benchmarks import Benchmarks
from ..machine import iter_machine_files
from ..results import iter_results_for_machine, iter_results_for_machine_and_hash
Expand All @@ -13,8 +13,6 @@
from ..environment import get_environments
from .. import util

from . import common_args


class Show(Command):
@classmethod
Expand Down
1 change: 0 additions & 1 deletion asv/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from . import util


WIN = (os.name == "nt")


Expand Down
5 changes: 2 additions & 3 deletions asv/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
import sys
import itertools
import subprocess
from .console import log
from . import util
from . import build_cache

from .console import log
from . import util, build_cache

WIN = (os.name == "nt")

Expand Down
10 changes: 5 additions & 5 deletions asv/extern/asizeof.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,18 @@ class and the ``... def`` suffix marks the *definition object*.
``_builtin_modules``.
''' # PYCHOK escape
import sys

if sys.version_info < (2, 6, 0):
raise NotImplementedError('%s requires Python 2.6 or newer' % ('asizeof',))

import types as Types
import warnings
import weakref as Weakref
# all imports listed explicitly to help PyChecker
from inspect import (isbuiltin, isclass, iscode, isframe, isfunction,
ismethod, ismodule, stack)
from inspect import isbuiltin, isclass, iscode, isframe, isfunction, ismethod, ismodule, stack
from math import log
from os import curdir, linesep
from struct import calcsize # type/class Struct only in Python 2.5+
import types as Types
import warnings
import weakref as Weakref

__all__ = ['adict', 'asized', 'asizeof', 'asizesof',
'Asized', 'Asizer', # classes
Expand Down
1 change: 1 addition & 0 deletions asv/extern/minify_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import re


def json_minify(string, strip_space=True):
tokenizer = re.compile(r'"|(/\*)|(\*/)|(//)|\n|\r')
in_string = False
Expand Down
4 changes: 1 addition & 3 deletions asv/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
import os
import traceback
import math
from . import util
from . import step_detect

from . import util, step_detect
from .util import is_na, mean_na, geom_mean_na


# This is the maximum number of points to include in summary graphs.
# It is based on the number of pixels in the summary graph display on
# a recent Retina MacBook Pro (3840 pixels across the screen, divided
Expand Down
3 changes: 1 addition & 2 deletions asv/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import sys
import textwrap

from . import console
from . import console, util
from .console import log, color_print
from . import util


def iter_machine_files(results_dir):
Expand Down
3 changes: 1 addition & 2 deletions asv/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
import os
import sys

from . import commands
from . import commands, util
from .console import log
from . import util


def main():
Expand Down
Loading