diff --git a/docs/conf.py b/docs/conf.py index 908c672309..8463eaaa16 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -3,7 +3,8 @@ # redis-py documentation build configuration file, created by # sphinx-quickstart on Fri Feb 8 00:47:08 2013. # -# This file is execfile()d with the current directory set to its containing dir. +# This file is execfile()d with the current directory set to its containing +# dir. # # Note that not all possible configuration values are present in this # autogenerated file. @@ -11,20 +12,21 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys, os +import os +import sys # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) -# -- General configuration ----------------------------------------------------- +# -- General configuration ---------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' -# Add any Sphinx extension module names here, as strings. They can be extensions -# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = [] # Add any paths that contain templates here, relative to this directory. @@ -66,7 +68,8 @@ # directories to ignore when looking for source files. exclude_patterns = ['_build'] -# The reST default role (used for this markup: `text`) to use for all documents. +# The reST default role (used for this markup: `text`) to use for all +# documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. @@ -87,7 +90,7 @@ #modindex_common_prefix = [] -# -- Options for HTML output --------------------------------------------------- +# -- Options for HTML output -------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. @@ -167,24 +170,25 @@ htmlhelp_basename = 'redis-pydoc' -# -- Options for LaTeX output -------------------------------------------------- +# -- Options for LaTeX output ------------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -#'papersize': 'letterpaper', + # The paper size ('letterpaper' or 'a4paper'). + #'papersize': 'letterpaper', -# The font size ('10pt', '11pt' or '12pt'). -#'pointsize': '10pt', + # The font size ('10pt', '11pt' or '12pt'). + #'pointsize': '10pt', -# Additional stuff for the LaTeX preamble. -#'preamble': '', + # Additional stuff for the LaTeX preamble. + #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). +# (source start file, target name, title, author, documentclass +# [howto/manual]). latex_documents = [ - ('index', 'redis-py.tex', u'redis-py Documentation', - u'Andy McCurdy, Mahdi Yusuf', 'manual'), + ('index', 'redis-py.tex', u'redis-py Documentation', + u'Andy McCurdy, Mahdi Yusuf', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -208,7 +212,7 @@ #latex_domain_indices = True -# -- Options for manual page output -------------------------------------------- +# -- Options for manual page output ------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). @@ -221,15 +225,15 @@ #man_show_urls = False -# -- Options for Texinfo output ------------------------------------------------ +# -- Options for Texinfo output ----------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'redis-py', u'redis-py Documentation', - u'Andy McCurdy, Mahdi Yusuf', 'redis-py', 'One line description of project.', - 'Miscellaneous'), + ('index', 'redis-py', u'redis-py Documentation', + u'Andy McCurdy, Mahdi Yusuf', 'redis-py', + 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. diff --git a/redis/client.py b/redis/client.py index 8db2b0ee15..33e4aaf49f 100644 --- a/redis/client.py +++ b/redis/client.py @@ -216,7 +216,8 @@ class StrictRedis(object): string_keys_to_dict('ZRANK ZREVRANK', int_or_none), { 'BGREWRITEAOF': ( - lambda r: nativestr(r) == 'Background rewriting of AOF file started' + lambda r: nativestr(r) == ('Background rewriting of AOF ' + 'file started') ), 'BGSAVE': lambda r: nativestr(r) == 'Background saving started', 'CLIENT': parse_client, @@ -1363,6 +1364,7 @@ def register_script(self, script): """ return Script(self, script) + class Redis(StrictRedis): """ Provides backwards compatibility with older versions of redis-py that diff --git a/redis/exceptions.py b/redis/exceptions.py index 34e381619d..af30cbf9fe 100644 --- a/redis/exceptions.py +++ b/redis/exceptions.py @@ -8,15 +8,19 @@ class RedisError(Exception): class AuthenticationError(RedisError): pass + class ServerError(RedisError): pass + class ConnectionError(ServerError): pass + class InvalidResponse(ServerError): pass + class ResponseError(RedisError): pass @@ -32,8 +36,10 @@ class PubSubError(RedisError): class WatchError(RedisError): pass + class NoScriptError(ResponseError): pass + class ExecAbortError(ResponseError): pass diff --git a/redis/utils.py b/redis/utils.py index 20cef6cc5a..7c04a71e0b 100644 --- a/redis/utils.py +++ b/redis/utils.py @@ -1,5 +1,6 @@ from redis.client import Redis + def from_url(url, db=None, **kwargs): """Returns an active Redis client generated from the given database URL. diff --git a/setup.py b/setup.py index ddb0e0fa7e..30c5cde4be 100644 --- a/setup.py +++ b/setup.py @@ -39,5 +39,5 @@ 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', - ] + ] ) diff --git a/tests/encoding.py b/tests/encoding.py index af02c42faf..b5aa58d586 100644 --- a/tests/encoding.py +++ b/tests/encoding.py @@ -45,6 +45,7 @@ def test_list_or_args(self): self.assertEquals(list_or_args(bfoo, []), [bfoo]) self.assertEquals(list_or_args(bfoo, [bfoo]), [bfoo, bfoo]) + class PythonParserEncodingTestCase(EncodingTestCase): def setUp(self): pool = ConnectionPool( diff --git a/tests/pipeline.py b/tests/pipeline.py index 138feccaad..a21c882296 100644 --- a/tests/pipeline.py +++ b/tests/pipeline.py @@ -4,6 +4,7 @@ import redis from redis._compat import b + class PipelineTestCase(unittest.TestCase): def setUp(self): self.client = redis.Redis(host='localhost', port=6379, db=9) diff --git a/tests/server_commands.py b/tests/server_commands.py index fb2accc8f8..9c0ee4f84f 100644 --- a/tests/server_commands.py +++ b/tests/server_commands.py @@ -9,6 +9,7 @@ from redis.client import parse_info import redis + class ServerCommandsTestCase(unittest.TestCase): def get_client(self, cls=redis.Redis): return cls(host='localhost', port=6379, db=9) @@ -1319,8 +1320,11 @@ def test_hmget(self): d = {'a': 1, 'b': 2, 'c': 3} self.assert_(self.client.hmset('foo', d)) self.assertEqual( - self.client.hmget('foo', ['a', 'b', 'c']), [b('1'), b('2'), b('3')]) - self.assertEqual(self.client.hmget('foo', ['a', 'c']), [b('1'), b('3')]) + self.client.hmget('foo', ['a', 'b', 'c']), [b('1'), b('2'), b('3')] + ) + self.assertEqual( + self.client.hmget('foo', ['a', 'c']), [b('1'), b('3')] + ) # using *args type args self.assertEquals(self.client.hmget('foo', 'a', 'c'), [b('1'), b('3')]) diff --git a/tox.ini b/tox.ini index f492a8bfcd..0663414fbd 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,9 @@ [tox] -envlist = py25, py26, py27, py32, py33 +envlist = py25, py26, py27, py32, py33, pep8 [testenv] commands = python setup.py test + +[testenv:pep8] +deps = pep8==1.3.3 +commands = pep8 --repeat --show-source --exclude=.venv,.tox,dist,doc,build,*.egg .