Skip to content

Commit

Permalink
Format code per pep8 guidelines
Browse files Browse the repository at this point in the history
A simple patch to enable pep8 in tox and format our code properly.

Signed-off-by: Paul Belanger <[email protected]>
  • Loading branch information
pabelanger committed Mar 30, 2013
1 parent 8063b10 commit 12f2e4f
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 27 deletions.
48 changes: 26 additions & 22 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,30 @@
# 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.
#
# 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.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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).
Expand All @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions redis/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -32,8 +36,10 @@ class PubSubError(RedisError):
class WatchError(RedisError):
pass


class NoScriptError(ResponseError):
pass


class ExecAbortError(ResponseError):
pass
1 change: 1 addition & 0 deletions redis/utils.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
]
]
)
1 change: 1 addition & 0 deletions tests/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions tests/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions tests/server_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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')])

Expand Down
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -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 .

0 comments on commit 12f2e4f

Please sign in to comment.