diff --git a/plugins/FunCommands.py b/plugins/FunCommands.py index 047be342e..a290e13ed 100644 --- a/plugins/FunCommands.py +++ b/plugins/FunCommands.py @@ -47,7 +47,6 @@ import sha import time import math import cmath -import types import string import random import urllib diff --git a/plugins/Infobot.py b/plugins/Infobot.py index 88a61bd6d..db81b7e67 100755 --- a/plugins/Infobot.py +++ b/plugins/Infobot.py @@ -116,7 +116,7 @@ class Infobot(callbacks.PrivmsgRegexp): self.db.commit() def forget(self, irc, msg, match): - r"^forget\s+(.+?)(?![?.! ]*)$" + r"^forget\s+(.+?)(?!\?+)[?.! ]*$" key = match.group(1) cursor = self.db.cursor() cursor.execute('DELETE FROM is_factoids WHERE key=%s', key) @@ -128,7 +128,7 @@ class Infobot(callbacks.PrivmsgRegexp): (nick, key) = match.groups() try: s = '%s wants you to know that %s' %(msg.nick,self.getFactoid(key)) - irc.queueMsg(irmcsgs.privmsg(nick, s)) + irc.queueMsg(ircmsgs.privmsg(nick, s)) except KeyError: irc.reply(msg, 'I don\'t know anything about %s' % key) @@ -157,7 +157,6 @@ class Infobot(callbacks.PrivmsgRegexp): key = match.group(1) try: irc.reply(msg, self.getFactoid(key)) - #irc.queueMsg(ircmsgs.privmsg(msg.args[0], self.getFactoid(key))) except KeyError: irc.reply(msg, self.getRandomSaying('dont_knows')) @@ -165,9 +164,9 @@ class Infobot(callbacks.PrivmsgRegexp): r"^info$" cursor = self.db.cursor() cursor.execute("SELECT COUNT(*) FROM is_factoids") - numIs = self.cursor.fetchone()[0] + numIs = cursor.fetchone()[0] cursor.execute("SELECT COUNT(*) FROM are_factoids") - numAre = self.cursor.fetchone()[0] + numAre = cursor.fetchone()[0] s = 'I have %s is factoids and %s are factoids' % (numIs, numAre) irc.reply(msg, s) diff --git a/plugins/KillBold.py b/plugins/KillBold.py index f10bb8700..861f65ea6 100644 --- a/plugins/KillBold.py +++ b/plugins/KillBold.py @@ -36,7 +36,6 @@ Removes all bold output by the bot. from baseplugin import * import ircmsgs -import privmsgs import callbacks diff --git a/plugins/Moobot.py b/plugins/Moobot.py index f77d5748d..84e41dcba 100644 --- a/plugins/Moobot.py +++ b/plugins/Moobot.py @@ -118,7 +118,6 @@ class Moobot(callbacks.Privmsg): """ text = privmsgs.getArgs(args) text = text.replace('_', '-') - L = [] def morseToLetter(m): s = m.group(1) return self._revcode.get(s, s) diff --git a/plugins/News.py b/plugins/News.py index 4faab3dcc..35c41f12e 100644 --- a/plugins/News.py +++ b/plugins/News.py @@ -69,6 +69,7 @@ class News(callbacks.Privmsg, ChannelDBHandler): added_by TEXT )""") db.commit() + return db def addnews(self, irc, msg, args): """[] diff --git a/plugins/RSS.py b/plugins/RSS.py index 94501956e..5808b7e9a 100644 --- a/plugins/RSS.py +++ b/plugins/RSS.py @@ -44,16 +44,11 @@ And you'll be able to call the command like this: slashdot Also includes a function for getting info about a specific feed, rssinfo. - -Commands include: - rsstitles - rssinfo """ from baseplugin import * import time -import operator import rssparser diff --git a/scripts/clean.py b/scripts/clean.py index 0754218ae..b91a3d6db 100755 --- a/scripts/clean.py +++ b/scripts/clean.py @@ -1,8 +1,8 @@ #!/usr/bin/env python -import os, sys, os.path, shutil +import os, os.path -def removeFiles(arg, dirname, names): +def removeFiles(_, dirname, names): for name in names: if name[-4:] in ('.pyc', 'pyo'): os.remove(os.path.join(dirname, name)) diff --git a/src/MiscCommands.py b/src/MiscCommands.py index 19c653a9a..788ebbc20 100755 --- a/src/MiscCommands.py +++ b/src/MiscCommands.py @@ -190,9 +190,9 @@ class MiscCommands(callbacks.Privmsg): Returns the module is in. """ command = callbacks.canonicalName(privmsgs.getArgs(args)) - Class = irc.findCallback(command) - if Class is not None: - irc.reply(msg, Class.name()) + cb = irc.findCallback(command) + if cb is not None: + irc.reply(msg, cb.name()) else: irc.error(msg, 'There is no such command %s' % command) diff --git a/src/asyncoreDrivers.py b/src/asyncoreDrivers.py index 8e42471e4..9a133c0db 100644 --- a/src/asyncoreDrivers.py +++ b/src/asyncoreDrivers.py @@ -45,7 +45,6 @@ import ircdb import world import drivers import ircmsgs -import ircutils import schedule class AsyncoreRunnerDriver(drivers.IrcDriver): diff --git a/src/bot.py b/src/bot.py index 93e99663e..60e3e0788 100755 --- a/src/bot.py +++ b/src/bot.py @@ -178,9 +178,8 @@ def main(): sys.exit(0) if __name__ == '__main__': - import sys if '-p' in sys.argv: - import profile, time + import profile sys.argv.remove('-p') profile.run('main()', '%i.prof' % time.time()) if '-O' in sys.argv: diff --git a/src/utils.py b/src/utils.py index ee4c70049..c48df4d2e 100755 --- a/src/utils.py +++ b/src/utils.py @@ -51,7 +51,7 @@ class HtmlToText(sgmllib.SGMLParser): self.tagReplace = tagReplace sgmllib.SGMLParser.__init__(self) - def unknown_starttag(self, tag, attrib): + def unknown_starttag(self, tag, attr): self.data.append(self.tagReplace) def unknown_endtag(self, tag): diff --git a/test/test.py b/test/test.py index b4302da97..7742ea91e 100755 --- a/test/test.py +++ b/test/test.py @@ -37,7 +37,6 @@ sys.path.insert(0, 'plugins') from fix import * import re -import sys import glob import time import os.path @@ -141,11 +140,11 @@ class PluginTestCase(unittest.TestCase): def assertRegexps(self, query, regexps): started = time.time() - total = len(expectedResponses)*self.timeout - while expectedResponses and time.time() - started < total: + total = len(regexps)*self.timeout + while regexps and time.time() - started < total: m = self._feedMsg(query) self.failUnless(m, msg) - regepx = expectedResponses.pop(0) + regexp = regexps.pop(0) self.failUnless(re.search(regexp, m.args[1]), '%r does not match %r' % (m.args[1], regexp)) self.failIf(time.time() - started > total) diff --git a/test/test_fix.py b/test/test_fix.py index 346c9d753..5e30bd382 100644 --- a/test/test_fix.py +++ b/test/test_fix.py @@ -33,8 +33,6 @@ from test import * -import pickle - class FunctionsTest(unittest.TestCase): def testCatch(self): def f(): @@ -46,7 +44,7 @@ class FunctionsTest(unittest.TestCase): revL = list(reviter(L)) L.reverse() self.assertEqual(L, revL, 'reviter didn\'t return reversed list') - for elt in reviter([]): + for _ in reviter([]): self.fail('reviter caused iteration over empty sequence') def testGroup(self): diff --git a/test/test_ircdb.py b/test/test_ircdb.py index ab2e54631..56f0840d7 100644 --- a/test/test_ircdb.py +++ b/test/test_ircdb.py @@ -35,7 +35,6 @@ import os import unittest import conf -import debug import ircdb import ircutils diff --git a/test/test_irclib.py b/test/test_irclib.py index 92c44ab3a..568cac085 100644 --- a/test/test_irclib.py +++ b/test/test_irclib.py @@ -31,7 +31,6 @@ from test import * -import copy import pickle import conf diff --git a/test/test_ircmsgs.py b/test/test_ircmsgs.py index a0e874fa0..dd371b887 100644 --- a/test/test_ircmsgs.py +++ b/test/test_ircmsgs.py @@ -47,7 +47,8 @@ class IrcMsgTestCase(unittest.TestCase): strmsg.replace(':', '') == strmsg) def testRepr(self): - from ircmsgs import IrcMsg + IrcMsg = ircmsgs.IrcMsg + ignore(IrcMsg) # Make pychecker happy. for msg in msgs: self.assertEqual(msg, eval(repr(msg))) diff --git a/test/test_structures.py b/test/test_structures.py index ec2b6ebff..e72baf8c1 100644 --- a/test/test_structures.py +++ b/test/test_structures.py @@ -138,7 +138,7 @@ class RingBufferTestCase(unittest.TestCase): self.assertRaises(ValueError, b.__setitem__, slice(0, 10), []) b[2:4] = L[2:4] self.assertEquals(b[2:4], L[2:4]) - for i in range(len(b)): + for _ in range(len(b)): b.append(0) b[2:4] = L[2:4] self.assertEquals(b[2:4], L[2:4]) diff --git a/tools/pycheckrc b/tools/pycheckrc index d72183a1d..c4a9e18f4 100644 --- a/tools/pycheckrc +++ b/tools/pycheckrc @@ -141,16 +141,16 @@ usesInput = 1 usesExec = 0 # ignore warnings from files under standard library -ignoreStandardLibrary = 0 +ignoreStandardLibrary = 1 # ignore warnings from the list of modules blacklist = ['Tkinter', 'wxPython', 'gtk', 'GTK', 'GDK', 'asynchat'] # ignore global variables not used if name is one of these values -variablesToIgnore = ['__version__', '__warningregistry__', '__all__', '__credits__', '__author__', '__email__'] +variablesToIgnore = ['__version__', '__warningregistry__', '__all__', '__credits__', '__author__', '__email__',] # ignore unused locals/arguments if name is one of these values -unusedNames = ['_', 'empty', 'unused', 'dummy', 'irc', 'args', 'msg', 'match'] +unusedNames = ['_', 'empty', 'unused', 'dummy', 'irc', 'args', 'msg', 'match', 'afterConnect', 'onStart', 'advanced', 'yn', 'expect', 'anything', 'something',] # ignore use of deprecated modules/functions deprecated = 1