diff --git a/src/callbacks.py b/src/callbacks.py index 6715410f5..60c3824b0 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -34,7 +34,6 @@ This module contains the basic callbacks for handling PRIVMSGs. """ import re -import sys import copy import time from . import shlex @@ -46,7 +45,7 @@ from . import (conf, ircdb, irclib, ircmsgs, ircutils, log, registry, utils, world) from .utils import minisix from .utils.iter import any, all -from .i18n import PluginInternationalization, internationalizeDocstring +from .i18n import PluginInternationalization _ = PluginInternationalization() def _addressed(nick, msg, prefixChars=None, nicks=None, @@ -318,7 +317,6 @@ class Tokenizer(object): ret.append(self._insideBrackets(lexer)) else: ret.append(self._handleToken(token)) - firstToken = False return ret def tokenize(self, s): @@ -372,7 +370,6 @@ def tokenize(s, channel=None): if conf.get(nested.pipeSyntax, channel): # No nesting, no pipe. pipe = True quotes = conf.get(conf.supybot.commands.quotes, channel) - start = time.time() try: ret = Tokenizer(brackets=brackets,pipe=pipe,quotes=quotes).tokenize(s) return ret diff --git a/src/commands.py b/src/commands.py index b494349d4..dd023cd9b 100644 --- a/src/commands.py +++ b/src/commands.py @@ -266,7 +266,7 @@ def getInt(irc, msg, args, state, type=_('integer'), p=None): def getNonInt(irc, msg, args, state, type=_('non-integer value')): try: - i = _int(args[0]) + _int(args[0]) state.errorInvalid(type, args[0]) except ValueError: state.args.append(args.pop(0)) @@ -303,7 +303,7 @@ def getId(irc, msg, args, state, kind=None): try: args[0] = args[0].lstrip('#') getInt(irc, msg, args, state, type=type) - except Exception as e: + except Exception: args[0] = original raise @@ -398,9 +398,9 @@ def getHostmask(irc, msg, args, state): def getBanmask(irc, msg, args, state): getHostmask(irc, msg, args, state) getChannel(irc, msg, args, state) - channel = state.channel banmaskstyle = conf.supybot.protocols.irc.banmask - state.args[-1] = banmaskstyle.makeBanmask(state.args[-1]) + state.args[-1] = banmaskstyle.makeBanmask(state.args[-1], + channel=state.channel) def getUser(irc, msg, args, state): try: @@ -431,7 +431,7 @@ def _getRe(f): s = args.pop(0) def isRe(s): try: - foo = f(s) + f(s) return True except ValueError: return False @@ -466,7 +466,7 @@ def getNick(irc, msg, args, state): def getSeenNick(irc, msg, args, state, errmsg=None): try: - foo = irc.state.nickToHostmask(args[0]) + irc.state.nickToHostmask(args[0]) state.args.append(args.pop(0)) except KeyError: if errmsg is None: @@ -850,7 +850,7 @@ class rest(context): args[:] = [' '.join(args)] try: super(rest, self).__call__(irc, msg, args, state) - except Exception as e: + except Exception: args[:] = original else: raise IndexError @@ -954,7 +954,7 @@ class commalist(context): if part: # trailing commas super(commalist, self).__call__(irc, msg, [part], st) state.args.append(st.args) - except Exception as e: + except Exception: args[:] = original raise diff --git a/src/conf.py b/src/conf.py index 8712ab040..3b08435be 100644 --- a/src/conf.py +++ b/src/conf.py @@ -307,7 +307,7 @@ def registerNetwork(name, password='', ssl=False, sasl_username='', _("""Determines what password will be used on %s. Yes, we know that technically passwords are server-specific and not network-specific, but this is the best we can do right now.""") % name, private=True)) - registryServers = registerGlobalValue(network, 'servers', Servers([], + registerGlobalValue(network, 'servers', Servers([], _("""Space-separated list of servers the bot will connect to for %s. Each will be tried in order, wrapping back to the first when the cycle is completed.""") % name)) diff --git a/src/dbi.py b/src/dbi.py index 89a1d8240..10aa3d651 100644 --- a/src/dbi.py +++ b/src/dbi.py @@ -142,7 +142,7 @@ class DirMapping(MappingInterface): def remove(self, id): try: os.remove(self._makeFilename(id)) - except EnvironmentError as e: + except EnvironmentError: raise NoRecordError(id) class FlatfileMapping(MappingInterface): diff --git a/src/drivers/Socket.py b/src/drivers/Socket.py index 760e97b26..cd96b1682 100644 --- a/src/drivers/Socket.py +++ b/src/drivers/Socket.py @@ -35,15 +35,13 @@ Contains simple socket drivers. Asyncore bugged (haha, pun!) me. from __future__ import division import os -import sys import time import errno import select import socket -from .. import (conf, drivers, log, schedule, utils, world) +from .. import (conf, drivers, log, utils, world) from ..utils import minisix -from ..utils.iter import imap from ..utils.str import decode_raw_line try: @@ -241,7 +239,6 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin): server = self._getNextServer() socks_proxy = getattr(conf.supybot.networks, self.irc.network) \ .socksproxy() - resolver = None try: if socks_proxy: import socks diff --git a/src/drivers/Twisted.py b/src/drivers/Twisted.py index fc3c6ed8c..dc65b90ae 100644 --- a/src/drivers/Twisted.py +++ b/src/drivers/Twisted.py @@ -28,7 +28,7 @@ # POSSIBILITY OF SUCH DAMAGE. ### -from .. import conf, drivers, ircmsgs, log +from .. import conf, drivers from twisted.names import client from twisted.internet import reactor, error diff --git a/src/drivers/__init__.py b/src/drivers/__init__.py index c41913fa0..1818fdb08 100644 --- a/src/drivers/__init__.py +++ b/src/drivers/__init__.py @@ -32,8 +32,6 @@ Contains various drivers (network, file, and otherwise) for using IRC objects. """ -import sys -import time import socket from .. import conf, ircmsgs, log as supylog, utils diff --git a/src/gpg.py b/src/gpg.py index 44615d7bb..45e17e60c 100644 --- a/src/gpg.py +++ b/src/gpg.py @@ -28,11 +28,9 @@ ### import os -import traceback import supybot.log as log import supybot.conf as conf -import supybot.world as world try: import gnupg diff --git a/src/httpserver.py b/src/httpserver.py index f3932d850..e08367748 100644 --- a/src/httpserver.py +++ b/src/httpserver.py @@ -32,7 +32,6 @@ An embedded and centralized HTTP server for Supybot's plugins. """ import os -import sys import cgi import socket from threading import Thread @@ -389,7 +388,6 @@ class Favicon(SupyHTTPServerCallback): def doGet(self, handler, path): response = None file_path = conf.supybot.servers.http.favicon() - found = False if file_path: try: icon = open(file_path, 'rb') @@ -399,12 +397,12 @@ class Favicon(SupyHTTPServerCallback): finally: icon.close() if response is not None: - filename = file_path.rsplit(os.sep, 1)[1] - if '.' in filename: - ext = filename.rsplit('.', 1)[1] - else: - ext = 'ico' # I have no idea why, but this headers are already sent. + # filename = file_path.rsplit(os.sep, 1)[1] + # if '.' in filename: + # ext = filename.rsplit('.', 1)[1] + # else: + # ext = 'ico' # self.send_header('Content-Length', len(response)) # self.send_header('Content-type', 'image/' + ext) # self.end_headers() @@ -461,7 +459,7 @@ def unhook(subdir): global http_servers assert isinstance(http_servers, list) for server in http_servers: - callback = server.unhook(subdir) + server.unhook(subdir) if len(server.callbacks) <= 0 and not configGroup.keepAlive(): server.shutdown() http_servers.remove(server) diff --git a/src/ircdb.py b/src/ircdb.py index 28c92fb4e..c1a0528f7 100644 --- a/src/ircdb.py +++ b/src/ircdb.py @@ -913,7 +913,7 @@ class IgnoresDB(object): else: expiration = 0 self.add(hostmask, expiration) - except Exception as e: + except Exception: log.error('Invalid line in ignores database: %q', line) fd.close() diff --git a/src/irclib.py b/src/irclib.py index 775ec9f66..fffa6479c 100644 --- a/src/irclib.py +++ b/src/irclib.py @@ -42,7 +42,7 @@ except ImportError: from . import conf, ircdb, ircmsgs, ircutils, log, utils, world from .utils.str import rsplit from .utils.iter import chain -from .utils.structures import queue, smallqueue, RingBuffer +from .utils.structures import smallqueue, RingBuffer ### # The base class for a callback to be registered with an Irc object. Shows @@ -1029,7 +1029,7 @@ class Irc(IrcCommandDispatcher, log.Firewalled): read()) authstring = base64.b64encode( private_key.sign(base64.b64decode(msg.args[0].encode()))).decode('utf-8') - except (BadDigestError, OSError, ValueError) as e: + except (BadDigestError, OSError, ValueError): authstring = "*" self.sendMsg(ircmsgs.IrcMsg(command='AUTHENTICATE', args=(authstring,))) diff --git a/src/ircmsgs.py b/src/ircmsgs.py index ff38a03f2..0ac502c48 100644 --- a/src/ircmsgs.py +++ b/src/ircmsgs.py @@ -36,7 +36,6 @@ object (which, as you'll read later, is quite...full-featured :)) """ import re -import sys import time import datetime import functools diff --git a/src/ircutils.py b/src/ircutils.py index af99be72a..f4df17b31 100644 --- a/src/ircutils.py +++ b/src/ircutils.py @@ -50,7 +50,7 @@ from . import utils from .utils import minisix from .version import version -from .i18n import PluginInternationalization, internationalizeDocstring +from .i18n import PluginInternationalization _ = PluginInternationalization() def debug(s, *args): diff --git a/src/log.py b/src/log.py index 487242c9d..b509823e9 100644 --- a/src/log.py +++ b/src/log.py @@ -109,7 +109,7 @@ class StdoutStreamHandler(logging.StreamHandler): if conf.supybot.log.stdout() and not conf.daemonized: try: logging.StreamHandler.emit(self, record) - except ValueError as e: # Raised if sys.stdout is closed. + except ValueError: # Raised if sys.stdout is closed. self.disable() error('Error logging to stdout. Removing stdout handler.') exception('Uncaught exception in StdoutStreamHandler:') @@ -360,14 +360,14 @@ def firewall(f, errorHandler=None): def m(self, *args, **kwargs): try: return f(self, *args, **kwargs) - except Exception as e: + except Exception: if testing: raise logException(self) if errorHandler is not None: try: return errorHandler(self, *args, **kwargs) - except Exception as e: + except Exception: logException(self, 'Uncaught exception in errorHandler') m = utils.python.changeFunctionName(m, f.__name__, f.__doc__) return m diff --git a/src/questions.py b/src/questions.py index cd15e8b12..b7d272c6b 100644 --- a/src/questions.py +++ b/src/questions.py @@ -37,7 +37,7 @@ from getpass import getpass as getPass from . import ansi, utils from .utils import minisix -from supybot.i18n import PluginInternationalization, internationalizeDocstring +from supybot.i18n import PluginInternationalization _ = PluginInternationalization() useBold = False diff --git a/src/registry.py b/src/registry.py index 23a95da89..9a8f7e3ad 100644 --- a/src/registry.py +++ b/src/registry.py @@ -30,7 +30,6 @@ import re import os -import sys import time import json import codecs @@ -148,7 +147,7 @@ def close(registry, filename, private=True): value._name) try: lines.append('# Default value: %s\n' % x) - except Exception as e: + except Exception: exception('Exception printing default value of %s:' % value._name) lines.append('###\n') diff --git a/src/schedule.py b/src/schedule.py index 0749a8c5a..1a66cc98b 100644 --- a/src/schedule.py +++ b/src/schedule.py @@ -139,7 +139,7 @@ class Schedule(drivers.IrcDriver): f = self.events.pop(name) try: f(*args, **kwargs) - except Exception as e: + except Exception: log.exception('Uncaught exception in scheduled function:') diff --git a/src/test.py b/src/test.py index 533d84dc7..b52c166b9 100644 --- a/src/test.py +++ b/src/test.py @@ -231,9 +231,9 @@ class PluginTestCase(SupyTestCase): MiscModule = plugin.loadPluginModule('Misc') OwnerModule = plugin.loadPluginModule('Owner') ConfigModule = plugin.loadPluginModule('Config') - _ = plugin.loadPluginClass(self.irc, MiscModule) - _ = plugin.loadPluginClass(self.irc, OwnerModule) - _ = plugin.loadPluginClass(self.irc, ConfigModule) + plugin.loadPluginClass(self.irc, MiscModule) + plugin.loadPluginClass(self.irc, OwnerModule) + plugin.loadPluginClass(self.irc, ConfigModule) if isinstance(self.plugins, str): self.plugins = [self.plugins] else: @@ -241,7 +241,7 @@ class PluginTestCase(SupyTestCase): if name not in ('Owner', 'Misc', 'Config'): module = plugin.loadPluginModule(name, ignoreDeprecation=True) - cb = plugin.loadPluginClass(self.irc, module) + plugin.loadPluginClass(self.irc, module) self.irc.addCallback(TestInstance) for (name, value) in self.config.items(): group = conf.supybot diff --git a/src/utils/__init__.py b/src/utils/__init__.py index bf6e86290..5e2dce60f 100644 --- a/src/utils/__init__.py +++ b/src/utils/__init__.py @@ -28,7 +28,6 @@ # POSSIBILITY OF SUCH DAMAGE. ### -import sys from . import minisix ### diff --git a/src/utils/crypt.py b/src/utils/crypt.py index a8b493459..f81f02e70 100644 --- a/src/utils/crypt.py +++ b/src/utils/crypt.py @@ -27,8 +27,6 @@ # POSSIBILITY OF SUCH DAMAGE. ### -import sys - from hashlib import md5 from hashlib import sha1 as sha diff --git a/src/utils/file.py b/src/utils/file.py index 6c3f9f326..768878f48 100644 --- a/src/utils/file.py +++ b/src/utils/file.py @@ -35,7 +35,6 @@ import shutil import os.path from . import crypt -from .iter import ifilter def contents(filename): with open(filename) as fd: diff --git a/src/utils/gen.py b/src/utils/gen.py index 56f70ada7..596d5379e 100644 --- a/src/utils/gen.py +++ b/src/utils/gen.py @@ -33,8 +33,6 @@ from __future__ import print_function import os import sys import ast -import time -import types import textwrap import warnings import functools @@ -45,7 +43,6 @@ import collections from . import crypt from .str import format from .file import mktemp -from .iter import imap from . import minisix from . import internationalization as _ @@ -230,24 +227,24 @@ class IterableMap(object): __iter__ = items def keys(self): - for (key, _) in self.items(): + for (key, __) in self.items(): yield key def values(self): - for (_, value) in self.items(): + for (__, value) in self.items(): yield value @warn_non_constant_time def __len__(self): ret = 0 - for _ in self.items(): + for __ in self.items(): ret += 1 return ret @warn_non_constant_time def __bool__(self): - for _ in self.items(): + for __ in self.items(): return True return False __nonzero__ = __bool__ @@ -300,7 +297,7 @@ class InsensitivePreservingDict(collections.MutableMapping): def keys(self): L = [] - for (k, _) in self.items(): + for (k, __) in self.items(): L.append(k) return L @@ -347,7 +344,7 @@ def stackTrace(frame=None, compact=True): def callTracer(fd=None, basename=True): if fd is None: fd = sys.stdout - def tracer(frame, event, _): + def tracer(frame, event, __): if event == 'call': code = frame.f_code lineno = frame.f_lineno diff --git a/src/utils/iter.py b/src/utils/iter.py index 0661f9f32..32e6ebd11 100644 --- a/src/utils/iter.py +++ b/src/utils/iter.py @@ -29,7 +29,6 @@ from __future__ import division -import sys import random from itertools import * diff --git a/src/utils/python.py b/src/utils/python.py index 59ae3a920..4d28cae71 100644 --- a/src/utils/python.py +++ b/src/utils/python.py @@ -32,7 +32,6 @@ import sys import types import fnmatch import threading -import traceback def universalImport(*names): """Attempt to import the given modules, in order, returning the first diff --git a/src/utils/str.py b/src/utils/str.py index cf6f5b039..dbfd83824 100644 --- a/src/utils/str.py +++ b/src/utils/str.py @@ -34,13 +34,12 @@ Simple utility functions related to strings. """ import re -import sys import time import string import textwrap from . import minisix -from .iter import all, any +from .iter import any from .structures import TwoWayDictionary from . import internationalization as _ diff --git a/src/utils/structures.py b/src/utils/structures.py index 0631e46cb..efe7483ec 100644 --- a/src/utils/structures.py +++ b/src/utils/structures.py @@ -32,7 +32,6 @@ Data structures for Python. """ import time -import types import collections diff --git a/src/utils/web.py b/src/utils/web.py index ad2ab18bf..81fb889eb 100644 --- a/src/utils/web.py +++ b/src/utils/web.py @@ -29,7 +29,6 @@ ### import re -import sys import base64 import socket @@ -174,7 +173,7 @@ def getUrl(url, size=None, headers=None, data=None, timeout=None): text = fd.read() else: text = fd.read(size) - except socket.timeout as e: + except socket.timeout: raise Error(TIMED_OUT) fd.close() return text