mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-13 16:14:18 +00:00
Configure flake8-import-order to use Google Style
This relies on two things: 1. Properly configuring flake8-import-order to use that style 2. Properly configuring flake8-import-order to know that flake8 is our application name.
This commit is contained in:
parent
3f434f7d1c
commit
8bc76f79de
17 changed files with 43 additions and 45 deletions
|
|
@ -3,6 +3,7 @@ from __future__ import print_function
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
import flake8
|
import flake8
|
||||||
from flake8 import checker
|
from flake8 import checker
|
||||||
|
|
@ -28,6 +29,10 @@ class Application(object):
|
||||||
:param str version:
|
:param str version:
|
||||||
The version of the program/application we're executing.
|
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
|
#: The name of the program being run
|
||||||
self.program = program
|
self.program = program
|
||||||
#: The version of the program being run
|
#: The version of the program being run
|
||||||
|
|
@ -254,6 +259,7 @@ class Application(object):
|
||||||
self.initialize(argv)
|
self.initialize(argv)
|
||||||
self.run_checks()
|
self.run_checks()
|
||||||
self.report_errors()
|
self.report_errors()
|
||||||
|
self.end_time = time.time()
|
||||||
|
|
||||||
def run(self, argv=None):
|
def run(self, argv=None):
|
||||||
# type: (Union[NoneType, List[str]]) -> NoneType
|
# type: (Union[NoneType, List[str]]) -> NoneType
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@
|
||||||
import collections
|
import collections
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
from flake8 import exceptions
|
from flake8 import exceptions
|
||||||
from flake8 import utils
|
from flake8 import utils
|
||||||
from flake8.plugins import notifier
|
from flake8.plugins import notifier
|
||||||
|
|
||||||
import pkg_resources
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
|
|
|
||||||
|
|
@ -11,11 +11,11 @@ else:
|
||||||
demandimport.disable()
|
demandimport.disable()
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from flake8 import utils
|
|
||||||
|
|
||||||
import pyflakes
|
import pyflakes
|
||||||
import pyflakes.checker
|
import pyflakes.checker
|
||||||
|
|
||||||
|
from flake8 import utils
|
||||||
|
|
||||||
|
|
||||||
def patch_pyflakes():
|
def patch_pyflakes():
|
||||||
"""Add error codes to Pyflakes messages."""
|
"""Add error codes to Pyflakes messages."""
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
"""Test aggregation of config files and command-line options."""
|
"""Test aggregation of config files and command-line options."""
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from flake8.main import options
|
from flake8.main import options
|
||||||
from flake8.options import aggregator
|
from flake8.options import aggregator
|
||||||
from flake8.options import manager
|
from flake8.options import manager
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
CLI_SPECIFIED_CONFIG = 'tests/fixtures/config_files/cli-specified.ini'
|
CLI_SPECIFIED_CONFIG = 'tests/fixtures/config_files/cli-specified.ini'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
"""Tests for the BaseFormatter object."""
|
"""Tests for the BaseFormatter object."""
|
||||||
import optparse
|
import optparse
|
||||||
|
|
||||||
|
import mock
|
||||||
|
import pytest
|
||||||
|
|
||||||
from flake8 import style_guide
|
from flake8 import style_guide
|
||||||
from flake8.formatting import base
|
from flake8.formatting import base
|
||||||
|
|
||||||
import mock
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
def options(**kwargs):
|
def options(**kwargs):
|
||||||
"""Create an optparse.Values instance."""
|
"""Create an optparse.Values instance."""
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
"""Tests for the Manager object for FileCheckers."""
|
"""Tests for the Manager object for FileCheckers."""
|
||||||
import errno
|
import errno
|
||||||
|
|
||||||
from flake8 import checker
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from flake8 import checker
|
||||||
|
|
||||||
|
|
||||||
def style_guide_mock(**kwargs):
|
def style_guide_mock(**kwargs):
|
||||||
"""Create a mock StyleGuide object."""
|
"""Create a mock StyleGuide object."""
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,11 @@ import configparser
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from flake8.options import config
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from flake8.options import config
|
||||||
|
|
||||||
CLI_SPECIFIED_FILEPATH = 'tests/fixtures/config_files/cli-specified.ini'
|
CLI_SPECIFIED_FILEPATH = 'tests/fixtures/config_files/cli-specified.ini'
|
||||||
BROKEN_CONFIG_PATH = 'tests/fixtures/config_files/broken.ini'
|
BROKEN_CONFIG_PATH = 'tests/fixtures/config_files/broken.ini'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
"""Unit tests for flake8.options.config.MergedConfigParser."""
|
"""Unit tests for flake8.options.config.MergedConfigParser."""
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import mock
|
||||||
|
import pytest
|
||||||
|
|
||||||
from flake8.options import config
|
from flake8.options import config
|
||||||
from flake8.options import manager
|
from flake8.options import manager
|
||||||
|
|
||||||
import mock
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def optmanager():
|
def optmanager():
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
"""Unit tests for the Notifier object."""
|
"""Unit tests for the Notifier object."""
|
||||||
from flake8.plugins import notifier
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from flake8.plugins import notifier
|
||||||
|
|
||||||
|
|
||||||
class _Listener(object):
|
class _Listener(object):
|
||||||
def __init__(self, error_code):
|
def __init__(self, error_code):
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
"""Unit tests for flake8.options.manager.Option."""
|
"""Unit tests for flake8.options.manager.Option."""
|
||||||
from flake8.options import manager
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from flake8.options import manager
|
||||||
|
|
||||||
|
|
||||||
def test_to_optparse():
|
def test_to_optparse():
|
||||||
"""Test conversion to an optparse.Option class."""
|
"""Test conversion to an optparse.Option class."""
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from flake8.options import manager
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from flake8.options import manager
|
||||||
|
|
||||||
TEST_VERSION = '3.0.0b1'
|
TEST_VERSION = '3.0.0b1'
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
"""Tests for flake8.plugins.manager.Plugin."""
|
"""Tests for flake8.plugins.manager.Plugin."""
|
||||||
import optparse
|
import optparse
|
||||||
|
|
||||||
|
import mock
|
||||||
|
import pytest
|
||||||
|
|
||||||
from flake8 import exceptions
|
from flake8 import exceptions
|
||||||
from flake8.plugins import manager
|
from flake8.plugins import manager
|
||||||
|
|
||||||
import mock
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
def test_load_plugin_fallsback_on_old_setuptools():
|
def test_load_plugin_fallsback_on_old_setuptools():
|
||||||
"""Verify we fallback gracefully to on old versions of setuptools."""
|
"""Verify we fallback gracefully to on old versions of setuptools."""
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
"""Tests for flake8.plugins.manager.PluginManager."""
|
"""Tests for flake8.plugins.manager.PluginManager."""
|
||||||
from flake8.plugins import manager
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
|
from flake8.plugins import manager
|
||||||
|
|
||||||
|
|
||||||
def create_entry_point_mock(name):
|
def create_entry_point_mock(name):
|
||||||
"""Create a mocked EntryPoint."""
|
"""Create a mocked EntryPoint."""
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
"""Tests for flake8.plugins.manager.PluginTypeManager."""
|
"""Tests for flake8.plugins.manager.PluginTypeManager."""
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
|
import mock
|
||||||
|
import pytest
|
||||||
|
|
||||||
from flake8 import exceptions
|
from flake8 import exceptions
|
||||||
from flake8.plugins import manager
|
from flake8.plugins import manager
|
||||||
|
|
||||||
import mock
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
TEST_NAMESPACE = "testing.plugin-type-manager"
|
TEST_NAMESPACE = "testing.plugin-type-manager"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
"""Tests for the flake8.style_guide.StyleGuide class."""
|
"""Tests for the flake8.style_guide.StyleGuide class."""
|
||||||
import optparse
|
import optparse
|
||||||
|
|
||||||
|
import mock
|
||||||
|
import pytest
|
||||||
|
|
||||||
from flake8 import style_guide
|
from flake8 import style_guide
|
||||||
from flake8.formatting import base
|
from flake8.formatting import base
|
||||||
from flake8.plugins import notifier
|
from flake8.plugins import notifier
|
||||||
|
|
||||||
import mock
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
def create_options(**kwargs):
|
def create_options(**kwargs):
|
||||||
"""Create and return an instance of optparse.Values."""
|
"""Create and return an instance of optparse.Values."""
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,11 @@
|
||||||
"""Tests for flake8's utils module."""
|
"""Tests for flake8's utils module."""
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from flake8 import utils
|
|
||||||
from flake8.plugins import manager as plugin_manager
|
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from flake8 import utils
|
||||||
|
from flake8.plugins import manager as plugin_manager
|
||||||
|
|
||||||
RELATIVE_PATHS = ["flake8", "pep8", "pyflakes", "mccabe"]
|
RELATIVE_PATHS = ["flake8", "pep8", "pyflakes", "mccabe"]
|
||||||
|
|
||||||
|
|
|
||||||
2
tox.ini
2
tox.ini
|
|
@ -121,3 +121,5 @@ ignore = D203
|
||||||
# :-(
|
# :-(
|
||||||
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,tests/fixtures/
|
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,tests/fixtures/
|
||||||
max-complexity = 10
|
max-complexity = 10
|
||||||
|
import-order-style = google
|
||||||
|
application-import-names = flake8
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue