summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Belanger <paul.belanger@polybeacon.com>2013-03-30 13:53:51 -0400
committerPaul Belanger <paul.belanger@polybeacon.com>2013-03-30 13:53:51 -0400
commit12f2e4fcd8153fb4ea9dc00ac79385b1059fb47a (patch)
tree537c61df2d334a1f49b4e93536f6b22d5e25be4c
parent8063b1021718f1eb1ab87530358e70fb171f5cba (diff)
downloadredis-py-12f2e4fcd8153fb4ea9dc00ac79385b1059fb47a.tar.gz
Format code per pep8 guidelines
A simple patch to enable pep8 in tox and format our code properly. Signed-off-by: Paul Belanger <paul.belanger@polybeacon.com>
-rw-r--r--docs/conf.py48
-rw-r--r--redis/client.py4
-rw-r--r--redis/exceptions.py6
-rw-r--r--redis/utils.py1
-rw-r--r--setup.py2
-rw-r--r--tests/encoding.py1
-rw-r--r--tests/pipeline.py1
-rw-r--r--tests/server_commands.py8
-rw-r--r--tox.ini6
9 files changed, 50 insertions, 27 deletions
diff --git a/docs/conf.py b/docs/conf.py
index 908c672..8463eaa 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 @@ release = '2.7.2'
# 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 @@ pygments_style = 'sphinx'
#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 @@ html_static_path = ['_static']
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_documents = [
#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_pages = [
#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 8db2b0e..33e4aaf 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 @@ class StrictRedis(object):
"""
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 34e3816..af30cbf 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 20cef6c..7c04a71 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 ddb0e0f..30c5cde 100644
--- a/setup.py
+++ b/setup.py
@@ -39,5 +39,5 @@ setup(
'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 af02c42..b5aa58d 100644
--- a/tests/encoding.py
+++ b/tests/encoding.py
@@ -45,6 +45,7 @@ class EncodingTestCase(unittest.TestCase):
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 138fecc..a21c882 100644
--- a/tests/pipeline.py
+++ b/tests/pipeline.py
@@ -4,6 +4,7 @@ import unittest
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 fb2accc..9c0ee4f 100644
--- a/tests/server_commands.py
+++ b/tests/server_commands.py
@@ -9,6 +9,7 @@ from redis._compat import (unichr, u, b, ascii_letters, iteritems, dictkeys,
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 @@ class ServerCommandsTestCase(unittest.TestCase):
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 f492a8b..0663414 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 .