From 2884a6b882d1c893816116d7c5330e8b4face569 Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Fri, 8 Apr 2022 20:29:20 -0700 Subject: Use hacking checks Change-Id: I5ed0829d1124c813fb3457cf45152a0f175cebea --- pyeclib/__init__.py | 22 ---------------------- pyeclib/core.py | 2 +- pyeclib/enum.py | 6 ++++-- setup.py | 28 ++++++++++++++-------------- test/test_pyeclib_api.py | 23 ++++++++++++++--------- test/test_pyeclib_c.py | 1 + tox.ini | 10 +++++++++- 7 files changed, 43 insertions(+), 49 deletions(-) diff --git a/pyeclib/__init__.py b/pyeclib/__init__.py index fc3df4e..e69de29 100644 --- a/pyeclib/__init__.py +++ b/pyeclib/__init__.py @@ -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. diff --git a/pyeclib/core.py b/pyeclib/core.py index 3fbbcd3..4c3d3a5 100644 --- a/pyeclib/core.py +++ b/pyeclib/core.py @@ -122,7 +122,7 @@ class ECPyECLibDriver(object): return required_fragments 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 def get_metadata(self, fragment, formatted=0): diff --git a/pyeclib/enum.py b/pyeclib/enum.py index 0e24fe9..a8a8084 100644 --- a/pyeclib/enum.py +++ b/pyeclib/enum.py @@ -815,8 +815,10 @@ class IntEnum(int, Enum): 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 = [] for name, member in enumeration.__members__.items(): if name != member.name: diff --git a/setup.py b/setup.py index 6eef16a..0004a4b 100644 --- a/setup.py +++ b/setup.py @@ -43,8 +43,8 @@ except ImportError: use_setuptools() from setuptools import setup -from setuptools import Extension from setuptools.command.install import install as _install +from setuptools import Extension platform_str = platform.platform() default_python_incdir = get_python_inc() @@ -232,25 +232,25 @@ setup(name='pyeclib', maintainer_email='kmgreen2@gmail.com, tusharsg@gmail.com', url='https://opendev.org/openstack/pyeclib', 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 ' 'implementing erasure codes. To obtain the best possible ' 'performance, the underlying erasure code algorithms are ' 'written in C.'), classifiers=[ - "Development Status :: 5 - Production/Stable", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Intended Audience :: Developers", - "License :: OSI Approved :: BSD License", + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", ], long_description=open('README.rst', 'r').read(), long_description_content_type='text/x-rst', diff --git a/test/test_pyeclib_api.py b/test/test_pyeclib_api.py index 31bedbd..1663920 100644 --- a/test/test_pyeclib_api.py +++ b/test/test_pyeclib_api.py @@ -23,13 +23,15 @@ import os import random -from string import ascii_letters, ascii_uppercase, digits +import resource +import string import sys import tempfile import unittest from distutils.version import StrictVersion from itertools import combinations + import six 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 ECInvalidParameter from pyeclib.ec_iface import PyECLib_EC_Types + from pyeclib.ec_iface import ALL_EC_TYPES from pyeclib.ec_iface import VALID_EC_TYPES + from pyeclib.ec_iface import LIBERASURECODE_VERSION -import resource if sys.version < '3': @@ -105,7 +108,7 @@ class TestPyECLibDriver(unittest.TestCase): size *= 1000 # 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,): buf = buf.encode('ascii') tmp_file = tempfile.NamedTemporaryFile() @@ -364,7 +367,7 @@ class TestPyECLibDriver(unittest.TestCase): return filesize = 1024 * 1024 * 3 - file_str = ''.join(random.choice(ascii_letters) + file_str = ''.join(random.choice(string.ascii_letters) for i in range(filesize)) file_bytes = file_str.encode('utf-8') @@ -423,7 +426,7 @@ class TestPyECLibDriver(unittest.TestCase): def test_verify_fragment_inline_chksum_fail(self): pyeclib_drivers = self.get_pyeclib_testspec("inline_crc32") filesize = 1024 * 1024 * 3 - file_str = ''.join(random.choice(ascii_letters) + file_str = ''.join(random.choice(string.ascii_letters) for i in range(filesize)) file_bytes = file_str.encode('utf-8') @@ -463,7 +466,7 @@ class TestPyECLibDriver(unittest.TestCase): pyeclib_drivers = self.get_pyeclib_testspec("inline_crc32") filesize = 1024 * 1024 * 3 - file_str = ''.join(random.choice(ascii_letters) + file_str = ''.join(random.choice(string.ascii_letters) for i in range(filesize)) file_bytes = file_str.encode('utf-8') @@ -542,7 +545,7 @@ class TestPyECLibDriver(unittest.TestCase): # Use 2 * segment size, because last segment may be # greater than segment_size # - char_set = ascii_uppercase + digits + char_set = string.ascii_uppercase + string.digits for segment_size in segment_sizes: segment_strings[segment_size] = ''.join( random.choice(char_set) for i in range(segment_size * 2)) @@ -815,8 +818,10 @@ class BackendsEnabledMetaclass(type): class TestBackendsEnabled(six.with_metaclass(BackendsEnabledMetaclass, 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__': diff --git a/test/test_pyeclib_c.py b/test/test_pyeclib_c.py index 478dcda..f7d3c1a 100644 --- a/test/test_pyeclib_c.py +++ b/test/test_pyeclib_c.py @@ -29,6 +29,7 @@ import time import unittest import pyeclib_c + from pyeclib.ec_iface import PyECLib_EC_Types from pyeclib.ec_iface import VALID_EC_TYPES diff --git a/tox.ini b/tox.ini index 1adec18..e7ca727 100644 --- a/tox.ini +++ b/tox.ini @@ -18,7 +18,7 @@ install_command = [testenv:pep8] skip_install = True deps= - flake8 + hacking commands= flake8 pyeclib/ setup.py test/ @@ -29,3 +29,11 @@ commands = {posargs} deps = -r{toxinidir}/doc/requirements.txt 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 -- cgit v1.2.1