From b65ef5b1d9d5540866b85e447b638740f59d817b Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Wed, 17 Jul 2019 11:41:14 -0700 Subject: [PATCH] Run recent YAPF version against code --- examples/benchmark.py | 18 +++++----- maxminddb/decoder.py | 1 - maxminddb/file.py | 1 - setup.py | 78 +++++++++++++++++++++---------------------- 4 files changed, 48 insertions(+), 50 deletions(-) diff --git a/examples/benchmark.py b/examples/benchmark.py index eea5a9d..80ebe8f 100644 --- a/examples/benchmark.py +++ b/examples/benchmark.py @@ -11,11 +11,14 @@ import timeit parser = argparse.ArgumentParser(description='Benchmark maxminddb.') -parser.add_argument( - '--count', default=250000, type=int, help='number of lookups') +parser.add_argument('--count', + default=250000, + type=int, + help='number of lookups') parser.add_argument('--mode', default=0, type=int, help='reader mode to use') -parser.add_argument( - '--file', default='GeoIP2-City.mmdb', help='path to mmdb file') +parser.add_argument('--file', + default='GeoIP2-City.mmdb', + help='path to mmdb file') args = parser.parse_args() @@ -27,9 +30,8 @@ def lookup_ip_address(): record = reader.get(str(ip)) -elapsed = timeit.timeit( - 'lookup_ip_address()', - setup='from __main__ import lookup_ip_address', - number=args.count) +elapsed = timeit.timeit('lookup_ip_address()', + setup='from __main__ import lookup_ip_address', + number=args.count) print(args.count / elapsed, 'lookups per second') diff --git a/maxminddb/decoder.py b/maxminddb/decoder.py index 00f8bb1..be6d15d 100644 --- a/maxminddb/decoder.py +++ b/maxminddb/decoder.py @@ -15,7 +15,6 @@ class Decoder(object): # pylint: disable=too-few-public-methods """Decoder for the data section of the MaxMind DB""" - def __init__(self, database_buffer, pointer_base=0, pointer_test=False): """Created a Decoder for a MaxMind DB diff --git a/maxminddb/file.py b/maxminddb/file.py index be65a7c..6b6d4e4 100644 --- a/maxminddb/file.py +++ b/maxminddb/file.py @@ -11,7 +11,6 @@ class FileBuffer(object): """A slice-able file reader""" - def __init__(self, database): self._handle = open(database, 'rb') self._size = os.fstat(self._handle.fileno()).st_size diff --git a/setup.py b/setup.py index 2a2fabc..b146f1d 100644 --- a/setup.py +++ b/setup.py @@ -96,8 +96,8 @@ def status_msgs(*msgs): def find_packages(location): packages = [] for pkg in ['maxminddb']: - for _dir, subdirectories, files in (os.walk( - os.path.join(location, pkg))): + for _dir, subdirectories, files in (os.walk(os.path.join( + location, pkg))): if '__init__.py' in files: tokens = _dir.split(os.sep)[len(location.split(os.sep)):] packages.append(".".join(tokens)) @@ -110,48 +110,46 @@ def run_setup(with_cext): if Feature: kwargs['features'] = { 'extension': - Feature( - "optional C implementation", - standard=True, - ext_modules=ext_module) + Feature("optional C implementation", + standard=True, + ext_modules=ext_module) } else: kwargs['ext_modules'] = ext_module - setup( - name='maxminddb', - version=VERSION, - author='Gregory Oschwald', - author_email='goschwald@maxmind.com', - description='Reader for the MaxMind DB format', - long_description=README, - url='http://www.maxmind.com/', - packages=find_packages('.'), - package_data={'': ['LICENSE']}, - package_dir={'maxminddb': 'maxminddb'}, - python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*', - include_package_data=True, - install_requires=requirements, - tests_require=['nose'], - test_suite='nose.collector', - license=LICENSE, - cmdclass=cmdclass, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Environment :: Web Environment', - 'Intended Audience :: Developers', - 'Intended Audience :: System Administrators', - 'License :: OSI Approved :: Apache Software License', - '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', - 'Topic :: Internet :: Proxy Servers', - 'Topic :: Internet', - ], - **kwargs) + setup(name='maxminddb', + version=VERSION, + author='Gregory Oschwald', + author_email='goschwald@maxmind.com', + description='Reader for the MaxMind DB format', + long_description=README, + url='http://www.maxmind.com/', + packages=find_packages('.'), + package_data={'': ['LICENSE']}, + package_dir={'maxminddb': 'maxminddb'}, + python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*', + include_package_data=True, + install_requires=requirements, + tests_require=['nose'], + test_suite='nose.collector', + license=LICENSE, + cmdclass=cmdclass, + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Web Environment', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: Apache Software License', + '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', + 'Topic :: Internet :: Proxy Servers', + 'Topic :: Internet', + ], + **kwargs) if PYPY or JYTHON: