Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

More pylint placating.

Removed nearly all pylint complaints.  Updated readme with info about
using tox.
  • Loading branch information...
commit 54a7e857ad4d4d1112fbc9f764a397cb5c4b6920 1 parent de5bd1a
@lyda authored
4 .pylintrc
@@ -28,7 +28,7 @@ argument-rgx=[a-z_][a-z0-9_]{2,30}$
# Note: s/2/1/ to allow two char var names.
@@ -53,7 +53,7 @@ generated-members=REQUEST,acl_users,aq_parent
5 README.rst
@@ -36,8 +36,10 @@ Contributions
Contributions are welcome! Please add unit tests for new features
or bug fixes. To run all the unit tests run ``./ test``.
+If you have `tox`_ installed, just run ``tox``.
-Unit tests are run on `Travis`_ for all supported python versions.
+Note that tests are run on `Travis`_ for all supported python
+versions whenever the tree on github is pushed to.
@@ -59,6 +61,7 @@ Credits
- `Maciej Blizinski`_: Potential use in opencsw pushed move to python.
- `Ville Skyttä`_: Sped up wordification, editor-friendly reporting.
+.. _`tox`:
.. _`Travis`:!/lyda/misspell-check
.. _`Kevin Lyda`:
.. _`myint`:
19 misspellings
@@ -1,4 +1,5 @@
+"""Check files against a list of commonly misspelled words."""
# For Python 2.5
from __future__ import with_statement
@@ -15,11 +16,13 @@ class Suggestions(object):
self.last_suggestions = {}
def _get_a_line(self, filename, lineno):
+ """Read a specific line from a file."""
# Perhaps caching this would be nice, but assuming not an insane
# number of misspellings.
return open(filename, 'r').readlines()[lineno - 1].rstrip()
def get_suggestion(self, filename, lineno, word, suggestions):
+ """Show line from file, a misspelled word and request replacement."""
if word not in self.last_suggestions:
self.last_suggestions[word] = suggestions[0]
line = self._get_a_line(filename, lineno)
@@ -35,6 +38,7 @@ class Suggestions(object):
def print_file_context(fn, target_line_num, context=5):
+ """Show a line from a file in context."""
line_num = 1
start_line = target_line_num - context
end_line = target_line_num + context
@@ -48,14 +52,8 @@ def print_file_context(fn, target_line_num, context=5):
line_num += 1
-def cmp_rev_line(a, b):
- file_cmp = cmp(a[0], b[0])
- if file_cmp == 0:
- return cmp(b[1], a[1])
- return file_cmp
def parse_file_list(filename):
+ """Show a line from a file in context."""
f = sys.stdin
if filename != '-':
@@ -69,11 +67,13 @@ def parse_file_list(filename):
def esc_sed(raw_text):
+ """Escape chars for a sed command on a shell command line."""
return raw_text.replace('"', '\\"').replace('/', '\\/')
def esc_file(raw_text):
- return raw_text.replace('"', '\\"')
+ """Escape chars for a file name on a shell command line."""
+ return raw_text.replace('\'', '\'"\'"\'')
# Output routines.
@@ -114,6 +114,7 @@ def output_sed_script(ms, parser, opts):
def main():
+ """main function."""
parser = optparse.OptionParser(
usage='Usage: misspellings [-f file_list] [files]',
description='Checks files for common spelling mistakes.',
@@ -150,7 +151,7 @@ def main():
ms = misspellings.Misspellings(files=files,
if opts.dump_ms:
- for word, correction in ms.dumpMisspellingList():
+ for word, correction in ms.dump_misspelling_list():
print('%s %s' % (word, correction))
if not opts.interactive:
if not opts.script_output:
@@ -1,7 +1,12 @@
+"""Misspellings module.
+ Take a list of files, check them against a list of misspelled words.
# For Python 2.5
from __future__ import with_statement
from collections import defaultdict
import os
import re
import sys
@@ -99,7 +104,8 @@ def suggestions(self, word):
set(self._misspelling_dict.get(word.lower(), [])))
return [self._same_case(source=word, destination=w) for w in suggestions]
- def dumpMisspellingList(self):
+ def dump_misspelling_list(self):
+ """Returns a list of misspelled words and corrections."""
results = []
for bad_word in sorted(self._misspelling_dict.keys()):
for correction in self._misspelling_dict[bad_word]:
6 tests/
@@ -37,15 +37,15 @@ def testGoodMSList(self):
with open(misspelling_file) as msf:
for unused_line in msf:
myint added a note

Typically in Python, the idiom is to use a single underscore as variable name to indicate that it isn't be used.

myint added a note

Though, considering the ".pylintrc" file, you might already know this.

@lyda Owner
lyda added a note

I didn't. However work's style guide calls for unused_ as a prefix so I just tend to use that. The pylintrc by default had dummy and _ as prefixes. The dummy one seemed obvious, but I wasn't sure how common the _ prefix was. To be honest I like that better. The unused_ and dummy prefixes seem too wordy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lines += 1
- self.assertEqual(len(ms.dumpMisspellingList()), lines)
+ self.assertEqual(len(ms.dump_misspelling_list()), lines)
def testExampleSameAsDefault(self):
dms = misspellings.Misspellings()
ems = misspellings.Misspellings(
misspelling_file=os.path.join(BASE_PATH, 'example_msl.txt'))
# wc -l example_msl.txt
- default_msl = dms.dumpMisspellingList()
- example_msl = ems.dumpMisspellingList()
+ default_msl = dms.dump_misspelling_list()
+ example_msl = ems.dump_misspelling_list()
for fn, msl in (('msl_ex', example_msl), ('msl_de', default_msl)):
f = open(os.path.join(LOG_PATH,
'testExampleSameAsDefault.%s.tmp' % fn), 'w')
Please sign in to comment.
Something went wrong with that request. Please try again.