Merge "Use hacking checks"

This commit is contained in:
Zuul 2022-04-14 05:05:51 +00:00 committed by Gerrit Code Review
commit 7f05a784fb
7 changed files with 43 additions and 49 deletions

View File

@ -1,22 +0,0 @@
# Copyright (c) 2013, Kevin Greenan (kmgreen2@gmail.com)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution. THIS SOFTWARE IS
# PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
# NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -122,7 +122,7 @@ class ECPyECLibDriver(object):
return required_fragments return required_fragments
def min_parity_fragments_needed(self): def min_parity_fragments_needed(self):
""" FIXME - fix this to return a function of HD """ """FIXME - fix this to return a function of HD"""
return 1 return 1
def get_metadata(self, fragment, formatted=0): def get_metadata(self, fragment, formatted=0):

View File

@ -815,8 +815,10 @@ class IntEnum(int, Enum):
def unique(enumeration): def unique(enumeration):
"""Class decorator that ensures only unique members exist """
in an enumeration.""" Class decorator that ensures only unique members exist
in an enumeration.
"""
duplicates = [] duplicates = []
for name, member in enumeration.__members__.items(): for name, member in enumeration.__members__.items():
if name != member.name: if name != member.name:

View File

@ -43,8 +43,8 @@ except ImportError:
use_setuptools() use_setuptools()
from setuptools import setup from setuptools import setup
from setuptools import Extension
from setuptools.command.install import install as _install from setuptools.command.install import install as _install
from setuptools import Extension
platform_str = platform.platform() platform_str = platform.platform()
default_python_incdir = get_python_inc() default_python_incdir = get_python_inc()
@ -233,25 +233,25 @@ setup(name='pyeclib',
maintainer_email='kmgreen2@gmail.com, tusharsg@gmail.com', maintainer_email='kmgreen2@gmail.com, tusharsg@gmail.com',
url='https://opendev.org/openstack/pyeclib', url='https://opendev.org/openstack/pyeclib',
project_urls={ project_urls={
'Bug Tracker': 'https://bugs.launchpad.net/pyeclib', 'Bug Tracker': 'https://bugs.launchpad.net/pyeclib',
}, },
description=('This library provides a simple Python interface for ' description=('This library provides a simple Python interface for '
'implementing erasure codes. To obtain the best possible ' 'implementing erasure codes. To obtain the best possible '
'performance, the underlying erasure code algorithms are ' 'performance, the underlying erasure code algorithms are '
'written in C.'), 'written in C.'),
classifiers=[ classifiers=[
"Development Status :: 5 - Production/Stable", "Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 2", "Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7", "Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.10",
"Intended Audience :: Developers", "Intended Audience :: Developers",
"License :: OSI Approved :: BSD License", "License :: OSI Approved :: BSD License",
], ],
long_description=open('README.rst', 'r').read(), long_description=open('README.rst', 'r').read(),
long_description_content_type='text/x-rst', long_description_content_type='text/x-rst',

View File

@ -23,13 +23,15 @@
import os import os
import random import random
from string import ascii_letters, ascii_uppercase, digits import resource
import string
import sys import sys
import tempfile import tempfile
import unittest import unittest
from distutils.version import StrictVersion from distutils.version import StrictVersion
from itertools import combinations from itertools import combinations
import six import six
import pyeclib.ec_iface import pyeclib.ec_iface
@ -40,10 +42,11 @@ from pyeclib.ec_iface import ECInsufficientFragments
from pyeclib.ec_iface import ECInvalidFragmentMetadata from pyeclib.ec_iface import ECInvalidFragmentMetadata
from pyeclib.ec_iface import ECInvalidParameter from pyeclib.ec_iface import ECInvalidParameter
from pyeclib.ec_iface import PyECLib_EC_Types from pyeclib.ec_iface import PyECLib_EC_Types
from pyeclib.ec_iface import ALL_EC_TYPES from pyeclib.ec_iface import ALL_EC_TYPES
from pyeclib.ec_iface import VALID_EC_TYPES from pyeclib.ec_iface import VALID_EC_TYPES
from pyeclib.ec_iface import LIBERASURECODE_VERSION from pyeclib.ec_iface import LIBERASURECODE_VERSION
import resource
if sys.version < '3': if sys.version < '3':
@ -105,7 +108,7 @@ class TestPyECLibDriver(unittest.TestCase):
size *= 1000 size *= 1000
# Create the dictionary of files to test with # Create the dictionary of files to test with
buf = ''.join(random.choice(ascii_letters) for i in range(size)) buf = ''.join(random.choice(string.ascii_letters) for i in range(size))
if sys.version_info >= (3,): if sys.version_info >= (3,):
buf = buf.encode('ascii') buf = buf.encode('ascii')
tmp_file = tempfile.NamedTemporaryFile() tmp_file = tempfile.NamedTemporaryFile()
@ -364,7 +367,7 @@ class TestPyECLibDriver(unittest.TestCase):
return return
filesize = 1024 * 1024 * 3 filesize = 1024 * 1024 * 3
file_str = ''.join(random.choice(ascii_letters) file_str = ''.join(random.choice(string.ascii_letters)
for i in range(filesize)) for i in range(filesize))
file_bytes = file_str.encode('utf-8') file_bytes = file_str.encode('utf-8')
@ -423,7 +426,7 @@ class TestPyECLibDriver(unittest.TestCase):
def test_verify_fragment_inline_chksum_fail(self): def test_verify_fragment_inline_chksum_fail(self):
pyeclib_drivers = self.get_pyeclib_testspec("inline_crc32") pyeclib_drivers = self.get_pyeclib_testspec("inline_crc32")
filesize = 1024 * 1024 * 3 filesize = 1024 * 1024 * 3
file_str = ''.join(random.choice(ascii_letters) file_str = ''.join(random.choice(string.ascii_letters)
for i in range(filesize)) for i in range(filesize))
file_bytes = file_str.encode('utf-8') file_bytes = file_str.encode('utf-8')
@ -463,7 +466,7 @@ class TestPyECLibDriver(unittest.TestCase):
pyeclib_drivers = self.get_pyeclib_testspec("inline_crc32") pyeclib_drivers = self.get_pyeclib_testspec("inline_crc32")
filesize = 1024 * 1024 * 3 filesize = 1024 * 1024 * 3
file_str = ''.join(random.choice(ascii_letters) file_str = ''.join(random.choice(string.ascii_letters)
for i in range(filesize)) for i in range(filesize))
file_bytes = file_str.encode('utf-8') file_bytes = file_str.encode('utf-8')
@ -542,7 +545,7 @@ class TestPyECLibDriver(unittest.TestCase):
# Use 2 * segment size, because last segment may be # Use 2 * segment size, because last segment may be
# greater than segment_size # greater than segment_size
# #
char_set = ascii_uppercase + digits char_set = string.ascii_uppercase + string.digits
for segment_size in segment_sizes: for segment_size in segment_sizes:
segment_strings[segment_size] = ''.join( segment_strings[segment_size] = ''.join(
random.choice(char_set) for i in range(segment_size * 2)) random.choice(char_set) for i in range(segment_size * 2))
@ -815,8 +818,10 @@ class BackendsEnabledMetaclass(type):
class TestBackendsEnabled(six.with_metaclass(BackendsEnabledMetaclass, class TestBackendsEnabled(six.with_metaclass(BackendsEnabledMetaclass,
unittest.TestCase)): unittest.TestCase)):
'''Based on TestPyECLibDriver.test_valid_algo above, but these tests '''
should *always* either pass or skip.''' Based on TestPyECLibDriver.test_valid_algo above, but these tests
should *always* either pass or skip.
'''
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -29,6 +29,7 @@ import time
import unittest import unittest
import pyeclib_c import pyeclib_c
from pyeclib.ec_iface import PyECLib_EC_Types from pyeclib.ec_iface import PyECLib_EC_Types
from pyeclib.ec_iface import VALID_EC_TYPES from pyeclib.ec_iface import VALID_EC_TYPES

10
tox.ini
View File

@ -18,7 +18,7 @@ install_command =
[testenv:pep8] [testenv:pep8]
skip_install = True skip_install = True
deps= deps=
flake8 hacking
commands= commands=
flake8 pyeclib/ setup.py test/ flake8 pyeclib/ setup.py test/
@ -29,3 +29,11 @@ commands = {posargs}
deps = deps =
-r{toxinidir}/doc/requirements.txt -r{toxinidir}/doc/requirements.txt
commands = python setup.py build_sphinx commands = python setup.py build_sphinx
[flake8]
# H101: Use TODO(NAME)
# H404: multi line docstring should start without a leading new line
# H405: multi line docstring summary not separated with an empty line
# W504: line break after binary operator
ignore = H101,H404,H405,W504
max-line-length = 88