Apply pep8 import order style

Update version of tox to 3.9.0 to support inline comments in tox.ini
Import pep8 test requirements directly in tox.ini and do not import all
the test-requirements
Update version of hacking
Fix import orders in various modules

Leave filter for imports in tests/ for the time being

Change-Id: Ia625036d1f50ae97880ef70335804228320a9c6d
This commit is contained in:
Riccardo Pittau 2021-03-08 12:32:39 +01:00
parent 964fec6a51
commit a714e096f3
56 changed files with 111 additions and 105 deletions

View File

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from openstack import service_description
from openstack.accelerator.v2 import _proxy as _proxy_v2
from openstack import service_description
class AcceleratorService(service_description.ServiceDescription):

View File

@ -9,11 +9,12 @@
# 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 openstack import proxy
from openstack.accelerator.v2 import accelerator_request as _arq
from openstack.accelerator.v2 import deployable as _deployable
from openstack.accelerator.v2 import device as _device
from openstack.accelerator.v2 import device_profile as _device_profile
from openstack.accelerator.v2 import accelerator_request as _arq
from openstack import proxy
class Proxy(proxy.Proxy):

View File

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from openstack import resource
from openstack import exceptions
from openstack import resource
class AcceleratorRequest(resource.Resource):

View File

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from openstack import service_description
from openstack.baremetal.v1 import _proxy
from openstack import service_description
class BaremetalService(service_description.ServiceDescription):

View File

@ -13,15 +13,14 @@
from openstack.baremetal.v1 import _common
from openstack.baremetal.v1 import allocation as _allocation
from openstack.baremetal.v1 import chassis as _chassis
from openstack.baremetal.v1 import conductor as _conductor
from openstack.baremetal.v1 import deploy_templates as _deploytemplates
from openstack.baremetal.v1 import driver as _driver
from openstack.baremetal.v1 import node as _node
from openstack.baremetal.v1 import port as _port
from openstack.baremetal.v1 import port_group as _portgroup
from openstack.baremetal.v1 import volume_connector as _volumeconnector
from openstack.baremetal.v1 import volume_target as _volumetarget
from openstack.baremetal.v1 import deploy_templates as _deploytemplates
from openstack.baremetal.v1 import conductor as _conductor
from openstack import exceptions
from openstack import proxy
from openstack import utils

View File

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from openstack import service_description
from openstack.baremetal_introspection.v1 import _proxy
from openstack import service_description
class BaremetalIntrospectionService(service_description.ServiceDescription):

View File

@ -13,13 +13,14 @@
# import types so that we can reference ListType in sphinx param declarations.
# We can't just use list, because sphinx gets confused by
# openstack.resource.Resource.list and openstack.resource2.Resource.list
import jsonpatch
import types # noqa
import warnings
from openstack.cloud import exc
import jsonpatch
from openstack.cloud import _normalize
from openstack.cloud import _utils
from openstack.cloud import exc
from openstack import utils

View File

@ -16,9 +16,9 @@
import types # noqa
import warnings
from openstack.cloud import exc
from openstack.cloud import _normalize
from openstack.cloud import _utils
from openstack.cloud import exc
from openstack import proxy
from openstack import utils

View File

@ -15,9 +15,9 @@
# openstack.resource.Resource.list and openstack.resource2.Resource.list
import types # noqa
from openstack.cloud import exc
from openstack.cloud import _normalize
from openstack.cloud import _utils
from openstack.cloud import exc
from openstack import utils

View File

@ -15,9 +15,9 @@
# openstack.resource.Resource.list and openstack.resource2.Resource.list
import types # noqa
from openstack.cloud import exc
from openstack.cloud import _normalize
from openstack.cloud import _utils
from openstack.cloud import exc
class CoeCloudMixin(_normalize.Normalizer):

View File

@ -16,16 +16,17 @@
import base64
import datetime
import functools
import iso8601
import operator
import threading
import time
import types # noqa
from openstack.cloud import exc
from openstack.cloud import meta
import iso8601
from openstack.cloud import _normalize
from openstack.cloud import _utils
from openstack.cloud import exc
from openstack.cloud import meta
from openstack import exceptions
from openstack import proxy
from openstack import utils

View File

@ -15,11 +15,11 @@
# openstack.resource.Resource.list and openstack.resource2.Resource.list
import types # noqa
from openstack import exceptions
from openstack import resource
from openstack.cloud import exc
from openstack.cloud import _normalize
from openstack.cloud import _utils
from openstack.cloud import exc
from openstack import exceptions
from openstack import resource
class DnsCloudMixin(_normalize.Normalizer):

View File

@ -19,10 +19,10 @@ import threading
import time
import types # noqa
from openstack.cloud import exc
from openstack.cloud import meta
from openstack.cloud import _normalize
from openstack.cloud import _utils
from openstack.cloud import exc
from openstack.cloud import meta
from openstack import exceptions
from openstack import proxy
from openstack import utils

View File

@ -17,9 +17,9 @@ import types # noqa
import munch
from openstack.cloud import exc
from openstack.cloud import _normalize
from openstack.cloud import _utils
from openstack.cloud import exc
from openstack import utils

View File

@ -15,9 +15,9 @@
# openstack.resource.Resource.list and openstack.resource2.Resource.list
import types # noqa
from openstack.cloud import exc
from openstack.cloud import _normalize
from openstack.cloud import _utils
from openstack.cloud import exc
from openstack import utils

View File

@ -13,13 +13,13 @@
# import types so that we can reference ListType in sphinx param declarations.
# We can't just use list, because sphinx gets confused by
# openstack.resource.Resource.list and openstack.resource2.Resource.list
import time
import threading
import time
import types # noqa
from openstack.cloud import exc
from openstack.cloud import _normalize
from openstack.cloud import _utils
from openstack.cloud import exc
from openstack import exceptions
from openstack import proxy

View File

@ -16,8 +16,8 @@
import threading
import types # noqa
from openstack.cloud import exc
from openstack.cloud import _normalize
from openstack.cloud import exc
class NetworkCommonCloudMixin(_normalize.Normalizer):

View File

@ -17,6 +17,7 @@
# the sdk resource objects.
import datetime
import munch
from openstack import resource

View File

@ -23,9 +23,9 @@ import urllib.parse
import keystoneauth1.exceptions
from openstack.cloud import exc
from openstack.cloud import _normalize
from openstack.cloud import _utils
from openstack.cloud import exc
from openstack import exceptions
from openstack import proxy
from openstack import utils

View File

@ -15,10 +15,10 @@
# openstack.resource.Resource.list and openstack.resource2.Resource.list
import types # noqa
from openstack.cloud import exc
from openstack.orchestration.util import event_utils
from openstack.cloud import _normalize
from openstack.cloud import _utils
from openstack.cloud import exc
from openstack.orchestration.util import event_utils
def _no_pending_stacks(stacks):

View File

@ -16,9 +16,9 @@
# import jsonpatch
import types # noqa
from openstack.cloud import exc
from openstack.cloud import _normalize
from openstack.cloud import _utils
from openstack.cloud import exc
from openstack import exceptions
from openstack import proxy

View File

@ -16,20 +16,21 @@ import contextlib
import fnmatch
import functools
import inspect
import jmespath
import munch
import netifaces
import re
import sre_constants
import time
import uuid
from decorator import decorator
import jmespath
import munch
import netifaces
import sre_constants
from openstack import _log
from openstack.cloud import exc
from openstack.cloud import meta
_decorated_methods = []

View File

@ -16,6 +16,7 @@
import argparse
import json
import sys
import yaml
import openstack.cloud

View File

@ -14,10 +14,10 @@
import functools
from openstack.cloud import _utils
from openstack.config import loader
from openstack import connection
from openstack import exceptions
from openstack.cloud import _utils
__all__ = ['OpenStackInventory']

View File

@ -12,14 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import munch
import ipaddress
import socket
import munch
from openstack import _log
from openstack import utils
from openstack.cloud import exc
from openstack import utils
NON_CALLABLES = (str, bool, dict, int, float, list, type(None))

View File

@ -19,29 +19,28 @@ import types # noqa
import warnings
import dogpile.cache
import keystoneauth1.exceptions
import keystoneauth1.session
import munch
import requests.models
import requestsexceptions
import keystoneauth1.exceptions
import keystoneauth1.session
from openstack import _log
from openstack.cloud import exc
from openstack.cloud import _floating_ip
from openstack.cloud import _object_store
from openstack.cloud import meta
from openstack.cloud import _utils
from openstack.cloud import exc
from openstack.cloud import meta
import openstack.config
from openstack.config import cloud_region as cloud_region_mod
from openstack import proxy
from openstack import utils
DEFAULT_SERVER_AGE = 5
DEFAULT_PORT_AGE = 5
DEFAULT_FLOAT_AGE = 5
_CONFIG_DOC_URL = _floating_ip._CONFIG_DOC_URL
DEFAULT_OBJECT_SEGMENT_SIZE = _object_store.DEFAULT_OBJECT_SEGMENT_SIZE
# This halves the current default for Swift
DEFAULT_MAX_FILE_SIZE = _object_store.DEFAULT_MAX_FILE_SIZE

View File

@ -10,11 +10,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from openstack.clustering.v1 import action as _action
from openstack import exceptions
from openstack import resource
from openstack.clustering.v1 import action as _action
class AsyncResource(resource.Resource):

View File

@ -10,11 +10,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from openstack.clustering.v1 import _async_resource
from openstack import resource
from openstack import utils
from openstack.clustering.v1 import _async_resource
class Cluster(_async_resource.AsyncResource):
resource_key = 'cluster'

View File

@ -10,11 +10,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from openstack.clustering.v1 import _async_resource
from openstack import resource
from openstack import utils
from openstack.clustering.v1 import _async_resource
class Node(_async_resource.AsyncResource):
resource_key = 'node'

View File

@ -10,8 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from openstack import service_description
from openstack.compute.v2 import _proxy
from openstack import service_description
class ComputeService(service_description.ServiceDescription):

View File

@ -9,6 +9,7 @@
# 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 warnings
from openstack.compute.v2 import aggregate as _aggregate
@ -23,13 +24,12 @@ from openstack.compute.v2 import server as _server
from openstack.compute.v2 import server_diagnostics as _server_diagnostics
from openstack.compute.v2 import server_group as _server_group
from openstack.compute.v2 import server_interface as _server_interface
from openstack.compute.v2 import (
server_remote_console as _server_remote_console)
from openstack.compute.v2 import server_ip
from openstack.compute.v2 import server_remote_console as _src
from openstack.compute.v2 import service as _service
from openstack.compute.v2 import volume_attachment as _volume_attachment
from openstack.network.v2 import security_group as _sg
from openstack import exceptions
from openstack.network.v2 import security_group as _sg
from openstack import proxy
from openstack import resource
from openstack import utils
@ -1768,7 +1768,7 @@ class Proxy(proxy.Proxy):
ServerRemoteConsole`
"""
server_id = resource.Resource._get_id(server)
return self._create(_server_remote_console.ServerRemoteConsole,
return self._create(_src.ServerRemoteConsole,
server_id=server_id, **attrs)
def get_server_console_url(self, server, console_type):
@ -1806,7 +1806,7 @@ class Proxy(proxy.Proxy):
# historically by OSC. We support it, but do not document either.
if utils.supports_microversion(self, '2.6'):
console = self._create(
_server_remote_console.ServerRemoteConsole,
_src.ServerRemoteConsole,
server_id=server.id,
type=console_type,
protocol=console_protocol)

View File

@ -11,8 +11,8 @@
# under the License.
from openstack.compute.v2 import metadata
from openstack.image.v2 import image
from openstack import exceptions
from openstack.image.v2 import image
from openstack import resource
from openstack import utils

View File

@ -11,7 +11,6 @@
# under the License.
from openstack import resource
from openstack import utils
CONSOLE_TYPE_PROTOCOL_MAPPING = {

View File

@ -14,8 +14,8 @@
import copy
import os.path
import warnings
import urllib
import warnings
from keystoneauth1 import discover
import keystoneauth1.exceptions.catalog
@ -36,13 +36,12 @@ try:
except ImportError:
influxdb = None
from openstack import version as openstack_version
from openstack import _log
from openstack.config import _util
from openstack.config import defaults as config_defaults
from openstack import exceptions
from openstack import proxy
from openstack import version as openstack_version
_logger = _log.setup_logging('openstack')
@ -53,7 +52,6 @@ SCOPE_KEYS = {
'system_scope'
}
# Sentinel for nonexistence
_ENOENT = object()

View File

@ -176,6 +176,7 @@ try to find it and if that fails, you would create it::
Additional information about the services can be found in the
:ref:`service-proxies` documentation.
"""
import concurrent.futures
import warnings
import weakref
@ -185,20 +186,17 @@ try:
except ImportError:
# For everyone else
import importlib_metadata
import concurrent.futures
import keystoneauth1.exceptions
import requestsexceptions
from openstack import _log
from openstack import _services_mixin
from openstack.cloud import openstackcloud as _cloud
from openstack.cloud import _accelerator
from openstack.cloud import _baremetal
from openstack.cloud import _block_storage
from openstack.cloud import _compute
from openstack.cloud import _clustering
from openstack.cloud import _coe
from openstack.cloud import _compute
from openstack.cloud import _dns
from openstack.cloud import _floating_ip
from openstack.cloud import _identity
@ -209,6 +207,7 @@ from openstack.cloud import _object_store
from openstack.cloud import _orchestration
from openstack.cloud import _security_group
from openstack.cloud import _shared_file_system
from openstack.cloud import openstackcloud as _cloud
from openstack import config as _config
from openstack.config import cloud_region
from openstack import exceptions

View File

@ -9,13 +9,14 @@
# 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 openstack import proxy
from openstack.dns.v2 import floating_ip as _fip
from openstack.dns.v2 import recordset as _rs
from openstack.dns.v2 import zone as _zone
from openstack.dns.v2 import zone_import as _zone_import
from openstack.dns.v2 import zone_export as _zone_export
from openstack.dns.v2 import zone_import as _zone_import
from openstack.dns.v2 import zone_transfer as _zone_transfer
from openstack.dns.v2 import floating_ip as _fip
from openstack import proxy
class Proxy(proxy.Proxy):

View File

@ -9,9 +9,9 @@
# 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 openstack import resource
from openstack.dns.v2 import _base
from openstack import resource
class FloatingIP(_base.Resource):

View File

@ -9,9 +9,9 @@
# 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 openstack import resource
from openstack.dns.v2 import _base
from openstack import resource
class Recordset(_base.Resource):

View File

@ -9,12 +9,12 @@
# 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 openstack.dns.v2 import _base
from openstack import exceptions
from openstack import resource
from openstack import utils
from openstack.dns.v2 import _base
class Zone(_base.Resource):
"""DNS ZONE Resource"""

View File

@ -9,10 +9,10 @@
# 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 openstack import exceptions
from openstack import resource
from openstack.dns.v2 import _base
from openstack import exceptions
from openstack import resource
class ZoneExport(_base.Resource):

View File

@ -9,10 +9,10 @@
# 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 openstack import exceptions
from openstack import resource
from openstack.dns.v2 import _base
from openstack import exceptions
from openstack import resource
class ZoneImport(_base.Resource):

View File

@ -9,9 +9,9 @@
# 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 openstack import resource
from openstack.dns.v2 import _base
from openstack import resource
class ZoneTransferBase(_base.Resource):

View File

@ -11,11 +11,10 @@
# under the License.
#
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives.asymmetric import utils
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives import serialization
from openstack.image.iterable_chunked_file import IterableChunkedFile

View File

@ -9,8 +9,9 @@
# 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 openstack.image import _download
from openstack import exceptions
from openstack.image import _download
from openstack import resource

View File

@ -18,8 +18,8 @@ from openstack.image import _base_proxy
from openstack.image.v2 import image as _image
from openstack.image.v2 import member as _member
from openstack.image.v2 import schema as _schema
from openstack.image.v2 import task as _task
from openstack.image.v2 import service_info as _si
from openstack.image.v2 import task as _task
from openstack import resource
from openstack import utils

View File

@ -10,10 +10,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from openstack import format
from urllib import parse
from openstack import format
class HREFToUUID(format.Formatter):

View File

@ -12,8 +12,8 @@
# 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 openstack.exceptions import HttpException
from openstack.exceptions import HttpException
from openstack import resource
from openstack import utils

View File

@ -19,14 +19,14 @@ import os
import time
from urllib import parse
from openstack import _log
from openstack.cloud import _utils
from openstack import exceptions
from openstack.object_store.v1 import account as _account
from openstack.object_store.v1 import container as _container
from openstack.object_store.v1 import obj as _obj
from openstack.object_store.v1 import info as _info
from openstack import exceptions
from openstack import _log
from openstack.object_store.v1 import obj as _obj
from openstack import proxy
from openstack.cloud import _utils
DEFAULT_OBJECT_SEGMENT_SIZE = 1073741824 # 1GB
DEFAULT_MAX_FILE_SIZE = (5 * 1024 * 1024 * 1024 + 2) / 2

View File

@ -11,6 +11,7 @@
# under the License.
import json
import yaml
if hasattr(yaml, 'CSafeLoader'):

View File

@ -17,10 +17,10 @@ import json
from urllib import parse
from urllib import request
from openstack import exceptions
from openstack.orchestration.util import environment_format
from openstack.orchestration.util import template_format
from openstack.orchestration.util import utils
from openstack import exceptions
def get_template_contents(template_file=None, template_url=None,

View File

@ -10,6 +10,8 @@
# License for the specific language governing permissions and limitations
# under the License.
from openstack import exceptions
from openstack.orchestration.util import template_utils
from openstack.orchestration.v1 import resource as _resource
from openstack.orchestration.v1 import software_config as _sc
from openstack.orchestration.v1 import software_deployment as _sd
@ -18,8 +20,6 @@ from openstack.orchestration.v1 import stack_environment as _stack_environment
from openstack.orchestration.v1 import stack_files as _stack_files
from openstack.orchestration.v1 import stack_template as _stack_template
from openstack.orchestration.v1 import template as _template
from openstack.orchestration.util import template_utils
from openstack import exceptions
from openstack import proxy
from openstack import resource

View File

@ -10,14 +10,14 @@
# License for the specific language governing permissions and limitations
# under the License.
import urllib
try:
import simplejson
JSONDecodeError = simplejson.scanner.JSONDecodeError
except ImportError:
JSONDecodeError = ValueError
import iso8601
import urllib
from keystoneauth1 import adapter
from openstack import _log

View File

@ -34,10 +34,10 @@ and then returned to the caller.
import collections
import inspect
import itertools
import operator
import urllib.parse
import jsonpatch
import operator
from keystoneauth1 import adapter
from keystoneauth1 import discover
import munch

View File

@ -256,7 +256,7 @@ class TestStack(base.TestCase):
dict(method='GET',
uri='{endpoint}/stacks/{name}?{resolve}'.format(
endpoint=fakes.ORCHESTRATION_ENDPOINT,
id=self.stack_id, name=self.stack_name, resolve=resolve),
name=self.stack_name, resolve=resolve),
status_code=404),
])

View File

@ -1,7 +1,7 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking>=3.0.1,<3.1.0 # Apache-2.0
hacking>=3.1.0,<4.0.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
ddt>=1.0.1 # MIT
@ -15,5 +15,3 @@ statsd>=3.3.0
stestr>=1.0.0 # Apache-2.0
testscenarios>=0.4 # Apache-2.0/BSD
testtools>=2.2.0 # MIT
doc8>=0.8.0 # Apache-2.0
Pygments>=2.2.0 # BSD license

17
tox.ini
View File

@ -1,5 +1,5 @@
[tox]
minversion = 3.1
minversion = 3.9.0
envlist = pep8,py38
skipsdist = True
ignore_basepython_conflict = True
@ -41,8 +41,14 @@ commands = stestr --test-path ./openstack/tests/functional/{env:OPENSTACKSDK_TES
stestr slowest
[testenv:pep8]
deps =
hacking>=3.1.0,<4.0.0 # Apache-2.0
flake8-import-order>=0.17.1 # LGPLv3
pycodestyle>=2.0.0,<2.7.0 # MIT
Pygments>=2.2.0 # BSD
doc8>=0.8.0 # Apache 2.0
commands =
flake8
flake8 {posargs}
doc8 doc/source README.rst
[testenv:venv]
@ -102,18 +108,21 @@ commands =
sphinx-build -a -E -W -d releasenotes/build/doctrees --keep-going -b html releasenotes/source releasenotes/build/html
[flake8]
application-import-names = openstack
# The following are ignored on purpose. It's not super worth it to fix them.
# However, if you feel strongly about it, patches will be accepted to fix them
# if they fix ALL of the occurances of one and only one of them.
# H238 New Style Classes are the default in Python3
# H306 Is about alphabetical imports - there's a lot to fix.
# H4 Are about docstrings and there's just a huge pile of pre-existing issues.
# W503 Is supposed to be off by default but in the latest pycodestyle isn't.
# Also, both openstacksdk and Donald Knuth disagree with the rule. Line
# breaks should occur before the binary operator for readability.
ignore = H238,H306,H4,W503
ignore = H238,H4,W503
import-order-style = pep8
show-source = True
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,openstack/_services_mixin.py
per-file-ignores =
openstack/tests/*:H306,I100,I201,I202
[flake8:local-plugins]
extension =