diff --git a/flake8/main/application.py b/flake8/main/application.py index e41a6c2..6739216 100644 --- a/flake8/main/application.py +++ b/flake8/main/application.py @@ -3,6 +3,7 @@ from __future__ import print_function import logging import sys +import time import flake8 from flake8 import checker @@ -28,6 +29,10 @@ class Application(object): :param str version: The version of the program/application we're executing. """ + #: The timestamp when the Application instance was instantiated. + self.start_time = time.time() + #: The timestamp when the Application finished reported errors. + self.end_time = None #: The name of the program being run self.program = program #: The version of the program being run @@ -254,6 +259,7 @@ class Application(object): self.initialize(argv) self.run_checks() self.report_errors() + self.end_time = time.time() def run(self, argv=None): # type: (Union[NoneType, List[str]]) -> NoneType diff --git a/flake8/plugins/manager.py b/flake8/plugins/manager.py index dffc2f6..d08d542 100644 --- a/flake8/plugins/manager.py +++ b/flake8/plugins/manager.py @@ -2,12 +2,12 @@ import collections import logging +import pkg_resources + from flake8 import exceptions from flake8 import utils from flake8.plugins import notifier -import pkg_resources - LOG = logging.getLogger(__name__) __all__ = ( diff --git a/flake8/plugins/pyflakes.py b/flake8/plugins/pyflakes.py index 7025baa..72d45fa 100644 --- a/flake8/plugins/pyflakes.py +++ b/flake8/plugins/pyflakes.py @@ -11,11 +11,11 @@ else: demandimport.disable() import os -from flake8 import utils - import pyflakes import pyflakes.checker +from flake8 import utils + def patch_pyflakes(): """Add error codes to Pyflakes messages.""" diff --git a/tests/integration/test_aggregator.py b/tests/integration/test_aggregator.py index d0a7971..929bdbf 100644 --- a/tests/integration/test_aggregator.py +++ b/tests/integration/test_aggregator.py @@ -1,12 +1,12 @@ """Test aggregation of config files and command-line options.""" import os +import pytest + from flake8.main import options from flake8.options import aggregator from flake8.options import manager -import pytest - CLI_SPECIFIED_CONFIG = 'tests/fixtures/config_files/cli-specified.ini' diff --git a/tests/unit/test_base_formatter.py b/tests/unit/test_base_formatter.py index a23a9cb..dc4a95c 100644 --- a/tests/unit/test_base_formatter.py +++ b/tests/unit/test_base_formatter.py @@ -1,13 +1,12 @@ """Tests for the BaseFormatter object.""" import optparse +import mock +import pytest + from flake8 import style_guide from flake8.formatting import base -import mock - -import pytest - def options(**kwargs): """Create an optparse.Values instance.""" diff --git a/tests/unit/test_checker_manager.py b/tests/unit/test_checker_manager.py index 5b91204..8240723 100644 --- a/tests/unit/test_checker_manager.py +++ b/tests/unit/test_checker_manager.py @@ -1,12 +1,11 @@ """Tests for the Manager object for FileCheckers.""" import errno -from flake8 import checker - import mock - import pytest +from flake8 import checker + def style_guide_mock(**kwargs): """Create a mock StyleGuide object.""" diff --git a/tests/unit/test_config_file_finder.py b/tests/unit/test_config_file_finder.py index 2c56685..2e1a1e5 100644 --- a/tests/unit/test_config_file_finder.py +++ b/tests/unit/test_config_file_finder.py @@ -3,12 +3,11 @@ import configparser import os import sys -from flake8.options import config - import mock - import pytest +from flake8.options import config + CLI_SPECIFIED_FILEPATH = 'tests/fixtures/config_files/cli-specified.ini' BROKEN_CONFIG_PATH = 'tests/fixtures/config_files/broken.ini' diff --git a/tests/unit/test_merged_config_parser.py b/tests/unit/test_merged_config_parser.py index baaa57a..eb57802 100644 --- a/tests/unit/test_merged_config_parser.py +++ b/tests/unit/test_merged_config_parser.py @@ -1,13 +1,12 @@ """Unit tests for flake8.options.config.MergedConfigParser.""" import os +import mock +import pytest + from flake8.options import config from flake8.options import manager -import mock - -import pytest - @pytest.fixture def optmanager(): diff --git a/tests/unit/test_notifier.py b/tests/unit/test_notifier.py index 8c001da..6a162cf 100644 --- a/tests/unit/test_notifier.py +++ b/tests/unit/test_notifier.py @@ -1,8 +1,8 @@ """Unit tests for the Notifier object.""" -from flake8.plugins import notifier - import pytest +from flake8.plugins import notifier + class _Listener(object): def __init__(self, error_code): diff --git a/tests/unit/test_option.py b/tests/unit/test_option.py index 45f9be7..67e2255 100644 --- a/tests/unit/test_option.py +++ b/tests/unit/test_option.py @@ -1,10 +1,9 @@ """Unit tests for flake8.options.manager.Option.""" -from flake8.options import manager - import mock - import pytest +from flake8.options import manager + def test_to_optparse(): """Test conversion to an optparse.Option class.""" diff --git a/tests/unit/test_option_manager.py b/tests/unit/test_option_manager.py index 0086585..53e8bf1 100644 --- a/tests/unit/test_option_manager.py +++ b/tests/unit/test_option_manager.py @@ -2,10 +2,10 @@ import optparse import os -from flake8.options import manager - import pytest +from flake8.options import manager + TEST_VERSION = '3.0.0b1' diff --git a/tests/unit/test_plugin.py b/tests/unit/test_plugin.py index d3d1185..f69bc05 100644 --- a/tests/unit/test_plugin.py +++ b/tests/unit/test_plugin.py @@ -1,13 +1,12 @@ """Tests for flake8.plugins.manager.Plugin.""" import optparse +import mock +import pytest + from flake8 import exceptions from flake8.plugins import manager -import mock - -import pytest - def test_load_plugin_fallsback_on_old_setuptools(): """Verify we fallback gracefully to on old versions of setuptools.""" diff --git a/tests/unit/test_plugin_manager.py b/tests/unit/test_plugin_manager.py index 5a50386..8991b96 100644 --- a/tests/unit/test_plugin_manager.py +++ b/tests/unit/test_plugin_manager.py @@ -1,8 +1,8 @@ """Tests for flake8.plugins.manager.PluginManager.""" -from flake8.plugins import manager - import mock +from flake8.plugins import manager + def create_entry_point_mock(name): """Create a mocked EntryPoint.""" diff --git a/tests/unit/test_plugin_type_manager.py b/tests/unit/test_plugin_type_manager.py index fb17a37..186c2e3 100644 --- a/tests/unit/test_plugin_type_manager.py +++ b/tests/unit/test_plugin_type_manager.py @@ -1,13 +1,12 @@ """Tests for flake8.plugins.manager.PluginTypeManager.""" import collections +import mock +import pytest + from flake8 import exceptions from flake8.plugins import manager -import mock - -import pytest - TEST_NAMESPACE = "testing.plugin-type-manager" diff --git a/tests/unit/test_style_guide.py b/tests/unit/test_style_guide.py index 4aa3c54..3d05528 100644 --- a/tests/unit/test_style_guide.py +++ b/tests/unit/test_style_guide.py @@ -1,14 +1,13 @@ """Tests for the flake8.style_guide.StyleGuide class.""" import optparse +import mock +import pytest + from flake8 import style_guide from flake8.formatting import base from flake8.plugins import notifier -import mock - -import pytest - def create_options(**kwargs): """Create and return an instance of optparse.Values.""" diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 54aa3a7..062f7f9 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -1,13 +1,11 @@ """Tests for flake8's utils module.""" import os -from flake8 import utils -from flake8.plugins import manager as plugin_manager - import mock - import pytest +from flake8 import utils +from flake8.plugins import manager as plugin_manager RELATIVE_PATHS = ["flake8", "pep8", "pyflakes", "mccabe"] diff --git a/tox.ini b/tox.ini index 9ba3f2c..c17f025 100644 --- a/tox.ini +++ b/tox.ini @@ -121,3 +121,5 @@ ignore = D203 # :-( exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,tests/fixtures/ max-complexity = 10 +import-order-style = google +application-import-names = flake8