From 91c24fd3e7492cb6707528fb451c58fe64fcbc3c Mon Sep 17 00:00:00 2001 From: paris-ci Date: Mon, 17 Aug 2015 22:30:28 +0200 Subject: [PATCH 1/2] Removed unused locals, parenthesis. --- Vagrantfile | 2 +- cloudbot/__main__.py | 2 +- cloudbot/hook.py | 2 +- plugins/attacks.py | 2 +- plugins/karma.py | 5 ++--- plugins/lastfm.py | 13 ++++++------- plugins/minecraft_ping.py | 1 - plugins/profiling.py | 4 +--- plugins/quote.py | 2 +- plugins/test/test_fishbans.py | 2 +- plugins/tvdb.py | 6 +++--- plugins/wordnik.py | 4 ++-- 12 files changed, 20 insertions(+), 25 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 9aab9025c..4289b8347 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -2,5 +2,5 @@ VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "ubuntu/trusty32" - config.vm.provision :shell, path: "vagrant-bootstrap.sh" + config.vm.provision :shell, path "vagrant-bootstrap.sh" end diff --git a/cloudbot/__main__.py b/cloudbot/__main__.py index 7a766c1ae..a1fa75244 100644 --- a/cloudbot/__main__.py +++ b/cloudbot/__main__.py @@ -38,7 +38,7 @@ def main(): original_sigint = signal.getsignal(signal.SIGINT) # define closure for signal handling - def exit_gracefully(signum, frame): + def exit_gracefully(): nonlocal stopped_while_restarting if not _bot: # we are currently in the process of restarting diff --git a/cloudbot/hook.py b/cloudbot/hook.py index af95f2d5b..4affaa772 100644 --- a/cloudbot/hook.py +++ b/cloudbot/hook.py @@ -7,7 +7,7 @@ valid_command_re = re.compile(r"^\w+$") -class _Hook(): +class _Hook: """ :type function: function :type type: str diff --git a/plugins/attacks.py b/plugins/attacks.py index f04577902..ab88834fe 100644 --- a/plugins/attacks.py +++ b/plugins/attacks.py @@ -103,7 +103,7 @@ def kill(text, conn, nick, action): @asyncio.coroutine @hook.command -def slap(text, action, nick, conn, notice): +def slap(text, action, nick, conn): """ -- Makes the bot slap .""" target = text.strip() diff --git a/plugins/karma.py b/plugins/karma.py index 7d56d9445..edb500e73 100644 --- a/plugins/karma.py +++ b/plugins/karma.py @@ -5,7 +5,7 @@ from sqlalchemy import select from cloudbot import hook -from cloudbot.util import timeformat, formatting, database +from cloudbot.util import timeformat, database CAN_DOWNVOTE = False @@ -109,12 +109,11 @@ def karma(text, db): if not query: return "That user has no karma :(" else: - karma_text = formatting.pluralize(query['up_karma'] - query['down_karma'], '\x02karma') return "{} has \x02{}\x02 karma!".format(text, query['up_karma'] - query['down_karma']) @hook.command('loved') -def loved(text, db): +def loved(db): """loved -- Shows the users with the most karma!""" query = db.execute( select([karma_table]) diff --git a/plugins/lastfm.py b/plugins/lastfm.py index 74be5b5cb..a021e4520 100644 --- a/plugins/lastfm.py +++ b/plugins/lastfm.py @@ -1,7 +1,6 @@ from datetime import datetime import requests -import random from sqlalchemy import Table, Column, PrimaryKeyConstraint, String @@ -123,13 +122,13 @@ def lastfm(text, nick, db, bot, notice): @hook.command("lastfmcompare", "compare", "lc") -def lastfmcompare(text, nick, bot, db): +def lastfmcompare(text, nick, bot,): """[user] ([user] optional) - displays the now playing (or last played) track of LastFM user [user]""" api_key = bot.config.get("api_keys", {}).get("lastfm") if not api_key: return "No last.fm API key set." if not text: - return("please specify a lastfm username to compare") + return "please specify a lastfm username to compare" try: user1, user2 = text.split() except: @@ -181,7 +180,7 @@ def lastfmcompare(text, nick, bot, db): @hook.command("ltop", "ltt", autohelp=False) -def toptrack(text, nick, db, bot, notice): +def toptrack(text, nick, bot): """Grabs a list of the top tracks for a last.fm username""" api_key = bot.config.get("api_keys", {}).get("lastfm") if not api_key: @@ -194,7 +193,7 @@ def toptrack(text, nick, db, bot, notice): else: username = get_account(nick) if not username: - return("No last.fm username specified and no last.fm username is set in the database.") + return "No last.fm username specified and no last.fm username is set in the database." params = { 'api_key': api_key, @@ -220,7 +219,7 @@ def toptrack(text, nick, db, bot, notice): @hook.command("lta", "topartist", autohelp=False) -def topartists(text, nick, db, bot, notice): +def topartists(text, nick, bot): """Grabs a list of the top artists for a last.fm username. You can set your lastfm username with .l username""" api_key = bot.config.get("api_keys", {}).get("lastfm") if not api_key: @@ -233,7 +232,7 @@ def topartists(text, nick, db, bot, notice): else: username = get_account(nick) if not username: - return("No last.fm username specified and no last.fm username is set in the database.") + return "No last.fm username specified and no last.fm username is set in the database." params = { 'api_key': api_key, 'method': 'user.gettopartists', diff --git a/plugins/minecraft_ping.py b/plugins/minecraft_ping.py index 18082db77..d9f34d294 100644 --- a/plugins/minecraft_ping.py +++ b/plugins/minecraft_ping.py @@ -46,7 +46,6 @@ def mcping(text): # I really hate people for putting colors IN THE VERSION # WTF REALLY THIS IS A THING NOW? - version = format_colors(s.version.name) if s.latency: return "{}\x0f - \x02{}\x0f - \x02{:.1f}ms\x02" \ diff --git a/plugins/profiling.py b/plugins/profiling.py index 6a526ea45..370613ca2 100644 --- a/plugins/profiling.py +++ b/plugins/profiling.py @@ -5,8 +5,6 @@ import traceback import sys -import cloudbot - PYMPLER_ENABLED = False if PYMPLER_ENABLED: @@ -115,7 +113,7 @@ def pympler_diff(): # # Provide an easy way to get a threaddump, by using SIGUSR1 (only on POSIX systems) if os.name == "posix": - def debug(sig, frame): + def debug(): print(get_thread_dump()) signal.signal(signal.SIGUSR1, debug) # Register handler diff --git a/plugins/quote.py b/plugins/quote.py index 90936efa5..f5f7d90cc 100644 --- a/plugins/quote.py +++ b/plugins/quote.py @@ -48,7 +48,7 @@ def add_quote(db, chan, target, sender, message): return "Quote added." -def del_quote(db, chan, nick, add_nick, msg): +def del_quote(db, nick, msg): """Deletes a quote from a nick""" query = qtable.update() \ .where(qtable.c.chan == 1) \ diff --git a/plugins/test/test_fishbans.py b/plugins/test/test_fishbans.py index bf5a7a4f0..790997ff1 100644 --- a/plugins/test/test_fishbans.py +++ b/plugins/test/test_fishbans.py @@ -30,7 +30,7 @@ reply_error = "Could not fetch ban data from the Fishbans API:" -class DummyBot(): +class DummyBot: user_agent = "CloudBot/3.0" diff --git a/plugins/tvdb.py b/plugins/tvdb.py index aecb3afa7..eb550f4fc 100644 --- a/plugins/tvdb.py +++ b/plugins/tvdb.py @@ -56,7 +56,7 @@ def get_episodes_for_series(series_name, api_key): return res -def get_episode_info(episode, api_key): +def get_episode_info(episode): first_aired = episode.findtext("FirstAired") try: @@ -103,7 +103,7 @@ def tv_next(text, bot=None): today = datetime.date.today() for episode in reversed(episodes): - ep_info = get_episode_info(episode, api_key) + ep_info = get_episode_info(episode) if ep_info is None: continue @@ -150,7 +150,7 @@ def tv_last(text, bot=None): today = datetime.date.today() for episode in reversed(episodes): - ep_info = get_episode_info(episode, api_key) + ep_info = get_episode_info(episode) if ep_info is None: continue diff --git a/plugins/wordnik.py b/plugins/wordnik.py index a0c28ae81..c47beda54 100644 --- a/plugins/wordnik.py +++ b/plugins/wordnik.py @@ -160,7 +160,7 @@ def antonym(text): # word of the day @hook.command("word", "wordoftheday", autohelp=False) -def wordoftheday(text, conn): +def wordoftheday(text): """returns the word of the day. To see past word of the day enter use the format yyyy-MM-dd. The specified date must be after 2009-08-10.""" if not api_key: return "This command requires an API key from wordnik.com." @@ -200,7 +200,7 @@ def wordoftheday(text, conn): # random word @hook.command("wordrandom", "randomword", autohelp=False) -def random_word(conn): +def random_word(): """Grabs a random word from wordnik.com""" if not api_key: return "This command requires an API key from wordnik.com." From 8133078fb39fda43f52a4ebdec7117023da4669d Mon Sep 17 00:00:00 2001 From: paris-ci Date: Mon, 17 Aug 2015 22:40:47 +0200 Subject: [PATCH 2/2] Fix an error --- Vagrantfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vagrantfile b/Vagrantfile index 4289b8347..9aab9025c 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -2,5 +2,5 @@ VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "ubuntu/trusty32" - config.vm.provision :shell, path "vagrant-bootstrap.sh" + config.vm.provision :shell, path: "vagrant-bootstrap.sh" end