Update hacking for Python3

The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix problems found.

Remove hacking and friends from lower-constraints, they are not needed
for installation.

Change-Id: Ia16e8cbccf7b38be8909aa94e66c04b99f200b89
(cherry picked from commit 2ebc766534eba6163e98b94a1f114ece18739fff)
This commit is contained in:
Andreas Jaeger 2020-04-19 21:01:47 +02:00 committed by Witold Bedyk
parent 498203d12f
commit 6fe7f9b304
9 changed files with 13 additions and 16 deletions

View File

@ -41,8 +41,8 @@ import os
import sys import sys
import time import time
from pykafka import KafkaClient
from pykafka.exceptions import NoBrokersAvailableError from pykafka.exceptions import NoBrokersAvailableError
from pykafka import KafkaClient
# Run this script only with Python 3 # Run this script only with Python 3
if sys.version_info.major != 3: if sys.version_info.major != 3:

View File

@ -7,19 +7,16 @@ debtcollector==1.2.0
docutils==0.11 docutils==0.11
extras==1.0.0 extras==1.0.0
fixtures==3.0.0 fixtures==3.0.0
flake8==2.5.5
future==0.16.0 future==0.16.0
gevent==1.2.2 gevent==1.2.2
gitdb==0.6.4 gitdb==0.6.4
GitPython==1.0.1 GitPython==1.0.1
greenlet==0.4.10 greenlet==0.4.10
hacking==0.12.0
httplib2==0.9.1 httplib2==0.9.1
iso8601==0.1.11 iso8601==0.1.11
kazoo==2.2 kazoo==2.2
keystoneauth1==3.4.0 keystoneauth1==3.4.0
linecache2==1.0.0 linecache2==1.0.0
mccabe==0.2.1
mock==2.0.0 mock==2.0.0
monotonic==0.6 monotonic==0.6
mox3==0.20.0 mox3==0.20.0
@ -36,8 +33,6 @@ oslo.serialization==2.18.0
oslo.utils==3.33.0 oslo.utils==3.33.0
oslotest==3.2.0 oslotest==3.2.0
pbr==2.0.0 pbr==2.0.0
pep8==1.5.7
pyflakes==0.8.1
PyMySQL==0.7.6 PyMySQL==0.7.6
pyparsing==2.1.0 pyparsing==2.1.0
python-mimeparse==1.6.0 python-mimeparse==1.6.0

View File

@ -201,7 +201,7 @@ class KafkaClient(object):
payload.partition) payload.partition)
payloads_by_broker[leader].append(payload) payloads_by_broker[leader].append(payload)
brokers_for_payloads.append(leader) brokers_for_payloads.append(leader)
except KafkaUnavailableError as e: except KafkaUnavailableError:
log.warning('KafkaUnavailableError attempting to send request ' log.warning('KafkaUnavailableError attempting to send request '
'on topic %s partition %d', payload.topic, payload.partition) 'on topic %s partition %d', payload.topic, payload.partition)
topic_partition = (payload.topic, payload.partition) topic_partition = (payload.topic, payload.partition)

View File

@ -94,7 +94,7 @@ def _send_upstream(queue, client, codec, batch_time, batch_size,
while not stop_event.is_set(): while not stop_event.is_set():
try: try:
client.reinit() client.reinit()
except Exception as e: except Exception:
log.warn( log.warn(
'Async producer failed to connect to brokers; backoff for %s(ms) before retrying', 'Async producer failed to connect to brokers; backoff for %s(ms) before retrying',
retry_options.backoff_ms) retry_options.backoff_ms)

View File

@ -12,8 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import six
import simplejson as json import simplejson as json
import six
from monasca_common.rest import exceptions from monasca_common.rest import exceptions

View File

@ -173,7 +173,7 @@ class TestMetricValidation(base.BaseTestCase):
"value": 5} "value": 5}
self.assertRaisesRegex( self.assertRaisesRegex(
metric_validator.InvalidDimensionKey, metric_validator.InvalidDimensionKey,
"invalid length \(0\) for dimension key", r"invalid length \(0\) for dimension key",
metric_validator.validate, metric) metric_validator.validate, metric)
def test_invalid_dimension_empty_value(self): def test_invalid_dimension_empty_value(self):
@ -183,7 +183,7 @@ class TestMetricValidation(base.BaseTestCase):
"value": 5} "value": 5}
self.assertRaisesRegex( self.assertRaisesRegex(
metric_validator.InvalidDimensionValue, metric_validator.InvalidDimensionValue,
"invalid length \(0\) for dimension value", r"invalid length \(0\) for dimension value",
metric_validator.validate, metric) metric_validator.validate, metric)
def test_invalid_dimension_non_str_key(self): def test_invalid_dimension_non_str_key(self):
@ -213,7 +213,7 @@ class TestMetricValidation(base.BaseTestCase):
"value": 5} "value": 5}
self.assertRaisesRegex( self.assertRaisesRegex(
metric_validator.InvalidDimensionKey, metric_validator.InvalidDimensionKey,
"invalid length \(256\) for dimension key", r"invalid length \(256\) for dimension key",
metric_validator.validate, metric) metric_validator.validate, metric)
def test_invalid_dimension_value_length(self): def test_invalid_dimension_value_length(self):
@ -223,7 +223,7 @@ class TestMetricValidation(base.BaseTestCase):
"value": 5} "value": 5}
self.assertRaisesRegex( self.assertRaisesRegex(
metric_validator.InvalidDimensionValue, metric_validator.InvalidDimensionValue,
"invalid length \(256\) for dimension value", r"invalid length \(256\) for dimension value",
metric_validator.validate, metric) metric_validator.validate, metric)
def test_invalid_dimension_key_restricted_characters(self): def test_invalid_dimension_key_restricted_characters(self):

View File

@ -16,9 +16,9 @@
import math import math
import re import re
import simplejson as json
import six import six
import sys import sys
import simplejson as json
# This is used to ensure that metrics with a timestamp older than # This is used to ensure that metrics with a timestamp older than
# RECENT_POINT_THRESHOLD_DEFAULT seconds (or the value passed in to # RECENT_POINT_THRESHOLD_DEFAULT seconds (or the value passed in to

View File

@ -2,8 +2,8 @@
# of appearance. Changing the order has an impact on the overall integration # of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
# Hacking already pins down pep8, pyflakes and flake8 # Hacking already pins down pep8, pyflakes and flake8
hacking>=3.0,<3.1.0 # Apache-2.0
bandit!=1.6.0,>=1.1.0 # Apache-2.0 bandit!=1.6.0,>=1.1.0 # Apache-2.0
hacking>=1.1.0,<1.2.0 # Apache-2.0
Babel!=2.4.0,>=2.3.4 # BSD Babel!=2.4.0,>=2.3.4 # BSD
coverage!=4.4,>=4.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD fixtures>=3.0.0 # Apache-2.0/BSD

View File

@ -87,7 +87,9 @@ show-source = True
# note: Due to the need to fork kafka-python, many pep8 violations occure. # note: Due to the need to fork kafka-python, many pep8 violations occure.
# All of the below ignores are caused by the forked kafka-python library # All of the below ignores are caused by the forked kafka-python library
# so when Monasca migrates to confluent-kafka, the below line can be removed. # so when Monasca migrates to confluent-kafka, the below line can be removed.
ignore = H101,H301,H404,H405 # In addition ignore for now:
# W504 line break after binary operator
ignore = H101,H301,H404,H405,W504
[testenv:lower-constraints] [testenv:lower-constraints]
setenv = {[testenv:py36]setenv} setenv = {[testenv:py36]setenv}