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: If92e1e5e79b63497ca8bd29c403bbf2f0e907778
This commit is contained in:
Andreas Jaeger 2020-04-07 10:37:49 +02:00
parent 1abd37695c
commit 4afdc0a3d4
14 changed files with 58 additions and 54 deletions

View File

@ -7,15 +7,12 @@ coverage==4.0
docutils==0.11
extras==1.0.0
fixtures==3.0.0
flake8==2.5.5
hacking==0.12.0
imagesize==0.7.1
iso8601==0.1.11
Jinja2==2.10
keystoneauth1==3.4.0
linecache2==1.0.0
MarkupSafe==1.0
mccabe==0.2.1
mock==2.0.0
mox3==0.20.0
openstackdocstheme==1.20.0
@ -23,9 +20,7 @@ os-client-config==1.28.0
oslosphinx==4.7.0
oslotest==3.2.0
pbr==2.0.0
pep8==1.5.7
prettytable==0.7.2
pyflakes==0.8.1
Pygments==2.2.0
pyparsing==2.1.0
pyperclip==1.5.27

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!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
hacking>=3.0,<3.1.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
oslotest>=3.2.0 # Apache-2.0

View File

@ -608,7 +608,7 @@ constraint_mapping = {
Constraint.MIN_LENGTH: MinLength,
Constraint.MAX_LENGTH: MaxLength,
Constraint.PATTERN: Pattern
}
}
def get_constraint_class(type):

View File

@ -21,7 +21,9 @@ from toscaparser.elements.statefulentitytype import StatefulEntityType
class NodeType(StatefulEntityType):
'''TOSCA built-in node type.'''
SECTIONS = (DERIVED_FROM, METADATA, PROPERTIES, VERSION, DESCRIPTION, ATTRIBUTES, REQUIREMENTS, CAPABILITIES, INTERFACES, ARTIFACTS) = \
SECTIONS = (DERIVED_FROM, METADATA, PROPERTIES, VERSION,
DESCRIPTION, ATTRIBUTES, REQUIREMENTS, CAPABILITIES,
INTERFACES, ARTIFACTS) = \
('derived_from', 'metadata', 'properties', 'version',
'description', 'attributes', 'requirements', 'capabilities',
'interfaces', 'artifacts')

View File

@ -55,7 +55,7 @@ class ScalarUnit(object):
ExceptionCollector.appendException(ValueError(msg))
def validate_scalar_unit(self):
regex = re.compile('([0-9.]+)\s*(\w+)')
regex = re.compile(r'([0-9.]+)\s*(\w+)')
try:
result = regex.match(str(self.value)).groups()
validateutils.str_to_num(result[0])
@ -75,7 +75,7 @@ class ScalarUnit(object):
unit = self.SCALAR_UNIT_DEFAULT
self.validate_scalar_unit()
regex = re.compile('([0-9.]+)\s*(\w+)')
regex = re.compile(r'([0-9.]+)\s*(\w+)')
result = regex.match(str(self.value)).groups()
converted = (float(validateutils.str_to_num(result[0]))
* self.SCALAR_UNIT_DICT[result[1]]
@ -112,7 +112,7 @@ scalarunit_mapping = {
ScalarUnit.SCALAR_UNIT_FREQUENCY: ScalarUnit_Frequency,
ScalarUnit.SCALAR_UNIT_SIZE: ScalarUnit_Size,
ScalarUnit.SCALAR_UNIT_TIME: ScalarUnit_Time,
}
}
def get_scalarunit_class(type):

View File

@ -34,7 +34,8 @@ class EntityTemplate(object):
('derived_from', 'properties', 'requirements', 'interfaces',
'capabilities', 'type', 'description', 'directives',
'attributes', 'artifacts', 'node_filter', 'copy')
REQUIREMENTS_SECTION = (NODE, CAPABILITY, RELATIONSHIP, OCCURRENCES, NODE_FILTER) = \
REQUIREMENTS_SECTION = (NODE, CAPABILITY, RELATIONSHIP, OCCURRENCES,
NODE_FILTER) = \
('node', 'capability', 'relationship',
'occurrences', 'node_filter')
# Special key names

View File

@ -822,6 +822,7 @@ class Token(Function):
def result(self):
return self
function_mappings = {
GET_PROPERTY: GetProperty,
GET_INPUT: GetInput,

View File

@ -235,7 +235,7 @@ class ImportsLoader(object):
import_template = dir_path + "/" +\
file_path[2]
if not os.path.isfile(import_template):
msg = (_('"%(import_template)s" is'
msg = (_('"%(import_template)s" is '
'not a valid file')
% {'import_template':
import_template})

View File

@ -235,8 +235,9 @@ class NodeTemplate(EntityTemplate):
DataEntity.validate_datatype('list', occurrences)
for value in occurrences:
DataEntity.validate_datatype('integer', value)
if len(occurrences) != 2 or not (0 <= occurrences[0] <= occurrences[1]) \
or occurrences[1] == 0:
if (len(occurrences) != 2
or not (0 <= occurrences[0] <= occurrences[1])
or occurrences[1] == 0):
ExceptionCollector.appendException(
InvalidPropertyValueError(what=(occurrences)))

View File

@ -165,11 +165,11 @@ def validate_timestamp(value):
class TOSCAVersionProperty(object):
VERSION_RE = re.compile('^(?P<major_version>([0-9][0-9]*))'
'(\.(?P<minor_version>([0-9][0-9]*)))?'
'(\.(?P<fix_version>([0-9][0-9]*)))?'
'(\.(?P<qualifier>([0-9A-Za-z]+)))?'
'(\-(?P<build_version>[0-9])*)?$')
VERSION_RE = re.compile(r'^(?P<major_version>([0-9][0-9]*))'
r'(\.(?P<minor_version>([0-9][0-9]*)))?'
r'(\.(?P<fix_version>([0-9][0-9]*)))?'
r'(\.(?P<qualifier>([0-9A-Za-z]+)))?'
r'(\-(?P<build_version>[0-9])*)?$')
def __init__(self, version):
self.version = str(version)

View File

@ -45,7 +45,7 @@ def load_yaml(path, a_file=True):
% {'path': path, 'code': e.code})
ExceptionCollector.appendException(URLException(what=msg))
return
except Exception as e:
except Exception:
raise
return yaml.load(f.read(), Loader=yaml_loader)

View File

@ -41,6 +41,10 @@ commands = oslo_debug_helper -t toscaparser/tests {posargs}
[flake8]
show-source = True
builtins = _
# Enable either of these:
# W503 line break before binary operator
# W504 line break after binary operator
ignore = W503,W504
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
[testenv:lower-constraints]