Bump hacking to 1.1.0

Fix the following new errors:
* E305 expected 2 blank lines after class or function definition, found 1
* E126 continuation line over-indented for hanging indent

max_line_length is set to 80 as the default value in pycodestyle is 79
but horizon uses 80 as max_line_length.

Ignore W504 and F405 by configurations.
Reasons of disabling them are explained as comments in tox.ini.

Change-Id: Iee8bcd60c30883fc8c74f08cf20af853cbb5e271
This commit is contained in:
Akihiro Motoki 2018-11-05 06:20:43 +09:00
parent a3a4b93d32
commit cebe212d00
21 changed files with 81 additions and 63 deletions

View File

@ -22,7 +22,7 @@ register = template.Library()
def shellfilter(value):
"""Replace HTML chars for shell usage."""
replacements = {'\\': '\\\\',
'`': '\`',
'`': '\\`',
"'": "\\'",
'"': '\\"'}
for search, repl in replacements.items():

View File

@ -30,6 +30,7 @@ def _lazy_join(separator, strings):
return separator.join([force_text(s)
for s in strings])
lazy_join = lazy(_lazy_join, six.text_type)

View File

@ -131,6 +131,7 @@ def memoized(func=None, max_size=None):
return decorate(func)
return decorate
# We can use @memoized for methods now too, because it uses weakref and so
# it doesn't keep the instances in memory forever. We might want to separate
# them in the future, however.

View File

@ -76,6 +76,7 @@ def validate_metadata(value):
if not len(keyval) == 2 or not keyval[0]:
raise ValidationError(error_msg)
# Same as POSIX [:print:]. Accordingly, diacritics are disallowed.
PRINT_REGEX = re.compile(r'^[\x20-\x7E]*$')

View File

@ -1266,7 +1266,7 @@ class OpenStackAuthTestsWebSSO(OpenStackAuthTestsMixin,
settings.WEBSSO_DEFAULT_REDIRECT = True
settings.WEBSSO_DEFAULT_REDIRECT_PROTOCOL = 'oidc'
settings.WEBSSO_DEFAULT_REDIRECT_REGION = (
settings.OPENSTACK_KEYSTONE_URL)
settings.OPENSTACK_KEYSTONE_URL)
url = reverse('login')
@ -1286,4 +1286,5 @@ class OpenStackAuthTestsWebSSO(OpenStackAuthTestsMixin,
self.assertRedirects(response, settings.WEBSSO_DEFAULT_REDIRECT_LOGOUT,
status_code=302, target_status_code=301)
load_tests = load_tests_apply_scenarios

View File

@ -197,7 +197,7 @@ def logout(request, login_url=None, **kwargs):
utils.get_websso_default_redirect_logout()):
auth_user.unset_session_user_variables(request)
return django_http.HttpResponseRedirect(
utils.get_websso_default_redirect_logout())
utils.get_websso_default_redirect_logout())
else:
return django_auth_views.logout_then_login(request,
login_url=login_url,

View File

@ -1841,6 +1841,7 @@ def is_router_enabled(request):
return (is_enabled_by_config('enable_router') and
is_extension_supported(request, 'router'))
# FEATURE_MAP is used to define:
# - related neutron extension name (key: "extension")
# - corresponding dashboard config (key: "config")

View File

@ -31,6 +31,7 @@ class AjaxError(Exception):
self.http_status = http_status
super(AjaxError, self).__init__(msg)
http_errors = exceptions.UNAUTHORIZED + exceptions.NOT_FOUND + \
exceptions.RECOVERABLE + (AjaxError, )
@ -147,6 +148,7 @@ def ajax(authenticated=True, data_required=False,
return _wrapped
return decorator
PARAM_MAPPING = {
'None': None,
'True': True,

View File

@ -32,4 +32,5 @@ class Admin(horizon.Dashboard):
else:
permissions = (tuple(utils.get_admin_permissions()),)
horizon.register(Admin)

View File

@ -150,9 +150,9 @@ class AdminIndexView(tables.DataTableView):
instances = self._get_instances(search_opts)
results = futurist_utils.call_functions_parallel(
(self._get_images, [tuple(instances)]),
self._get_flavors,
self._get_tenants)
(self._get_images, [tuple(instances)]),
self._get_flavors,
self._get_tenants)
image_dict, flavor_dict, tenant_dict = results
non_api_filter_info = (

View File

@ -36,11 +36,11 @@ urlpatterns = [
url(r'^create/$', views.CreateView.as_view(), name='create'),
url(NETWORKS % 'update', views.UpdateView.as_view(), name='update'),
url(NETWORKS % 'detail', views.DetailView.as_view(), name='detail'),
url(NETWORKS % 'detail\?tab=network_tabs__ports_tab$',
url(NETWORKS % r'detail\?tab=network_tabs__ports_tab$',
views.DetailView.as_view(), name='ports_tab'),
url(NETWORKS % 'detail\?tab=network_tabs__agents_tab$',
url(NETWORKS % r'detail\?tab=network_tabs__agents_tab$',
views.DetailView.as_view(), name='agents_tab'),
url(NETWORKS % 'detail\?tab=network_tabs__subnets_tab$',
url(NETWORKS % r'detail\?tab=network_tabs__subnets_tab$',
views.DetailView.as_view(), name='subnets_tab'),
url(NETWORKS % 'agents/add',
agent_views.AddView.as_view(), name='adddhcpagent'),

View File

@ -25,7 +25,7 @@ urlpatterns = [
url(r'^(?P<identity_provider_id>[^/]+)/detail/$',
views.DetailView.as_view(), name='detail'),
url(r'^(?P<identity_provider_id>[^/]+)/detail/'
'\?tab=idp_details__protocols$',
r'\?tab=idp_details__protocols$',
views.DetailView.as_view(),
name='protocols_tab'),
url(r'^(?P<identity_provider_id>[^/]+)/update/$',

View File

@ -26,4 +26,5 @@ class Project(horizon.Dashboard):
has_project = request.user.token.project.get('id') is not None
return super(Project, self).can_access(context) and has_project
horizon.register(Project)

View File

@ -43,6 +43,7 @@ IMAGE_FORMAT_CHOICES = IMAGE_BACKEND_SETTINGS.get('image_formats', [])
class ImageURLField(forms.URLField):
default_validators = [validators.URLValidator(schemes=["http", "https"])]
if api.glance.get_image_upload_mode() == 'direct':
FileField = forms.ExternalFileField
CreateParent = six.with_metaclass(forms.ExternalUploadMeta,

View File

@ -32,12 +32,12 @@ NETWORKS = r'^(?P<network_id>[^/]+)/%s$'
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^create$', views.CreateView.as_view(), name='create'),
url(NETWORKS % 'detail(\?tab=network_tabs__overview)?$',
url(NETWORKS % r'detail(\?tab=network_tabs__overview)?$',
views.DetailView.as_view(),
name='detail'),
url(NETWORKS % 'detail\?tab=network_tabs__ports_tab$',
url(NETWORKS % r'detail\?tab=network_tabs__ports_tab$',
views.DetailView.as_view(), name='ports_tab'),
url(NETWORKS % 'detail\?tab=network_tabs__subnets_tab$',
url(NETWORKS % r'detail\?tab=network_tabs__subnets_tab$',
views.DetailView.as_view(), name='subnets_tab'),
url(NETWORKS % 'update', views.UpdateView.as_view(), name='update'),
url(NETWORKS % 'subnets/create', subnet_views.CreateView.as_view(),

View File

@ -139,6 +139,8 @@ def find_apache_log_dir():
if os.path.exists(log_dir) and os.path.isdir(log_dir):
return log_dir
return DEFAULT_LOG_DIR
context['LOGDIR'] = find_apache_log_dir()

View File

@ -72,9 +72,9 @@ class FloatingipsPage(basepage.BaseNavigationPage):
def allocate_floatingip(self):
floatingip_form = self.floatingips_table.allocate_ip()
floatingip_form.submit()
ip = re.compile('(([2][5][0-5]\.)|([2][0-4][0-9]\.)'
'|([0-1]?[0-9]?[0-9]\.)){3}(([2][5][0-5])|'
'([2][0-4][0-9])|([0-1]?[0-9]?[0-9]))')
ip = re.compile(r'(([2][5][0-5]\.)|([2][0-4][0-9]\.)'
r'|([0-1]?[0-9]?[0-9]\.)){3}(([2][5][0-5])|'
r'([2][0-4][0-9])|([0-1]?[0-9]?[0-9]))')
match = ip.search((self._get_element(
*self._floatingips_fadein_popup_locator)).text)
floatingip = str(match.group())

View File

@ -688,48 +688,48 @@ class KeystoneRestTestCase(test.TestCase):
def test_service_catalog_get(self):
request = self.mock_rest_request()
request.user = mock.MagicMock(**{'service_catalog': [
{'endpoints': [
{'url': 'http://cool_url/image',
'interface': 'admin',
'region': 'RegionOne',
'region_id': 'RegionOne',
'id': 'test'},
{'url': 'http://cool_url/image',
'interface': 'public',
'region': 'RegionOne',
'region_id': 'RegionOne',
'id': 'test'},
{'url': 'http://cool_url/image',
'interface': 'internal',
'region': 'RegionOne',
'region_id': 'RegionOne',
'id': 'test'}],
'type': 'image',
'id': '2b5bc2e59b094f898a43f5e8ce446240',
'name': 'glance'},
{'endpoints': [
{'url': 'http://cool_url/volume/v2/test',
'interface': 'public',
'region': 'RegionOne',
'region_id': 'RegionOne',
'id': '29a629afb80547ea9baa4266e97b4cb5'},
{'url': 'http://cool_url/volume/v2/test',
'interface': 'admin',
'region': 'RegionOne',
'region_id': 'RegionOne',
'id': '29a629afb80547ea9baa4266e97b4cb5'}],
'type': 'volumev2',
'id': '55ef272cfa714e54b8f2046c157b027d',
'name': 'cinderv2'},
{'endpoints': [
{'url': 'http://cool_url/compute/v2/check',
'interface': 'internal',
'region': 'RegionOne',
'region_id': 'RegionOne',
'id': 'e8c440e025d94355ab82c78cc2062129'}],
'type': 'compute_legacy',
'id': 'b7f1d3f4119643508d5ca2325eb8af87',
'name': 'nova_legacy'}]})
{'endpoints': [
{'url': 'http://cool_url/image',
'interface': 'admin',
'region': 'RegionOne',
'region_id': 'RegionOne',
'id': 'test'},
{'url': 'http://cool_url/image',
'interface': 'public',
'region': 'RegionOne',
'region_id': 'RegionOne',
'id': 'test'},
{'url': 'http://cool_url/image',
'interface': 'internal',
'region': 'RegionOne',
'region_id': 'RegionOne',
'id': 'test'}],
'type': 'image',
'id': '2b5bc2e59b094f898a43f5e8ce446240',
'name': 'glance'},
{'endpoints': [
{'url': 'http://cool_url/volume/v2/test',
'interface': 'public',
'region': 'RegionOne',
'region_id': 'RegionOne',
'id': '29a629afb80547ea9baa4266e97b4cb5'},
{'url': 'http://cool_url/volume/v2/test',
'interface': 'admin',
'region': 'RegionOne',
'region_id': 'RegionOne',
'id': '29a629afb80547ea9baa4266e97b4cb5'}],
'type': 'volumev2',
'id': '55ef272cfa714e54b8f2046c157b027d',
'name': 'cinderv2'},
{'endpoints': [
{'url': 'http://cool_url/compute/v2/check',
'interface': 'internal',
'region': 'RegionOne',
'region_id': 'RegionOne',
'id': 'e8c440e025d94355ab82c78cc2062129'}],
'type': 'compute_legacy',
'id': 'b7f1d3f4119643508d5ca2325eb8af87',
'name': 'nova_legacy'}]})
response = keystone.ServiceCatalog().get(request)
self.assertStatusCode(response, 200)
content = [{'endpoints': [

View File

@ -33,11 +33,11 @@ class GlanceApiTests(test.APIMockTestCase):
@override_settings(API_RESULT_PAGE_SIZE=2)
@mock.patch.object(api.glance, 'glanceclient')
def test_long_url(self, mock_glanceclient):
servers = self.servers.list()*100
api_images = self.images_api.list()*100
servers = self.servers.list() * 100
api_images = self.images_api.list() * 100
instances_img_ids = [instance.image.get('id') for instance in
servers if hasattr(instance, 'image')]
expected_images = self.images.list()*100
expected_images = self.images.list() * 100
glanceclient = mock_glanceclient.return_value
mock_images_list = glanceclient.images.list
mock_images_list.return_value = iter(api_images)

View File

@ -7,7 +7,7 @@
# be installed in a specific order.
#
# Hacking should appear first in case something else depends on pep8
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
hacking>=1.1.0 # Apache-2.0
#
bandit>=1.4.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0

View File

@ -173,7 +173,12 @@ basepython = python3
[flake8]
filename = *.py,django.wsgi
exclude = .git,.tox,dist,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject,node_modules,openstack_dashboard/enabled/*
ignore =
# W504 line break after binary operator
# (W503 and W504 are incompatible and we need to choose one of them.
# Existing codes follows W503, so we disable W504.)
# F405 TEMPLATES may be undefined, or defined from star imports
# (because it is not easy to avoid this in openstack_dashboard.test.settings)
ignore = W504,F405
# Enable the following hacking rules which are disabled by default
# H106 Do not put vim configuration in source files.
# H203 Use assertIs(Not)None to check for None.
@ -182,6 +187,7 @@ ignore =
# H904 Delay string interpolations at logging calls.
enable-extensions=H106,H203,H204,H205,H904
max-complexity = 20
max_line_length = 80
# flake8-import-order configurations
import-order-style = pep8