From 646a0437f7d1612a50f22f23ce9bc2ceae8981b7 Mon Sep 17 00:00:00 2001 From: Dooley_labs Date: Fri, 5 Apr 2019 12:36:50 -0400 Subject: [PATCH] Fixes typos and patches raise exceptions using %s instead of .format() (#130) --- disco/bot/plugin.py | 6 +++--- disco/gateway/client.py | 2 +- disco/types/message.py | 2 +- disco/util/functional.py | 6 +++--- disco/util/serializer.py | 2 +- disco/voice/client.py | 2 +- disco/voice/playable.py | 2 +- docs/bot_tutorial/building_block_listeners.md | 10 +++++----- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/disco/bot/plugin.py b/disco/bot/plugin.py index a19f773..9fb248c 100644 --- a/disco/bot/plugin.py +++ b/disco/bot/plugin.py @@ -66,7 +66,7 @@ def find_loadable_plugins(mod): class BasePluginDeco(object): Prio = Priority - # TODO: dont smash class methods + # TODO: don't smash class methods @classmethod def add_meta_deco(cls, meta): def deco(f): @@ -234,7 +234,7 @@ class Plugin(LoggingClass, PluginDeco): self.storage = bot.storage self.config = config - # General declartions + # General declarations self.listeners = [] self.commands = [] self.schedules = {} @@ -445,7 +445,7 @@ class Plugin(LoggingClass, PluginDeco): repeat : bool Whether this schedule is repeating (or one time). init : bool - Whether to run this schedule once immediatly, or wait for the first + Whether to run this schedule once immediately, or wait for the first scheduled iteration. kwargs: dict kwargs which will be passed to executed `func` diff --git a/disco/gateway/client.py b/disco/gateway/client.py index 58ccc5b..75acd42 100644 --- a/disco/gateway/client.py +++ b/disco/gateway/client.py @@ -194,7 +194,7 @@ class GatewayClient(LoggingClass): if isinstance(error, KeyboardInterrupt): self.shutting_down = True self.ws_event.set() - raise Exception('WS recieved error: %s', error) + raise Exception('WS received error: {}'.format(error)) def on_open(self): if self.zlib_stream_enabled: diff --git a/disco/types/message.py b/disco/types/message.py index a613d12..27f063d 100644 --- a/disco/types/message.py +++ b/disco/types/message.py @@ -346,7 +346,7 @@ class Message(SlottedModel): IDs for roles mentioned within this message. embeds : list[`MessageEmbed`] Embeds for this message. - attachments : list[`MessageAttachment`] + attachments : dict[`MessageAttachment`] Attachments for this message. reactions : list[`MessageReaction`] Reactions for this message. diff --git a/disco/util/functional.py b/disco/util/functional.py index d2e0273..0a06048 100644 --- a/disco/util/functional.py +++ b/disco/util/functional.py @@ -9,10 +9,10 @@ def take(seq, count): Args ---- - seq : sequnce or generator - The sequnce to take elements from. + seq : sequence or generator + The sequence to take elements from. count : int - The number of elments to take. + The number of elements to take. """ for _ in range(count): i = next(seq, NO_MORE_SENTINEL) diff --git a/disco/util/serializer.py b/disco/util/serializer.py index a481a9d..de6264a 100644 --- a/disco/util/serializer.py +++ b/disco/util/serializer.py @@ -12,7 +12,7 @@ class Serializer(object): @classmethod def check_format(cls, fmt): if fmt not in cls.FORMATS: - raise Exception('Unsupported serilization format: {}'.format(fmt)) + raise Exception('Unsupported serialization format: {}'.format(fmt)) @staticmethod def json(): diff --git a/disco/voice/client.py b/disco/voice/client.py index 2a48346..8f6ce40 100644 --- a/disco/voice/client.py +++ b/disco/voice/client.py @@ -406,7 +406,7 @@ class VoiceClient(LoggingClass): channel_id = self.server_id if not channel_id: - raise VoiceException('[%s] cannot connect to an empty channel id', self) + raise VoiceException('[{}] cannot connect to an empty channel id'.format(self)) if self.channel_id == channel_id: if self.state == VoiceState.CONNECTED: diff --git a/disco/voice/playable.py b/disco/voice/playable.py index 55e37f2..a1eff5b 100644 --- a/disco/voice/playable.py +++ b/disco/voice/playable.py @@ -12,7 +12,7 @@ from disco.voice.opus import OpusEncoder try: - from cStringIO import cStringIO as BufferedIO + from io import StringIO as BufferedIO except ImportError: if six.PY2: from StringIO import StringIO as BufferedIO diff --git a/docs/bot_tutorial/building_block_listeners.md b/docs/bot_tutorial/building_block_listeners.md index 3a664e5..04ff44c 100644 --- a/docs/bot_tutorial/building_block_listeners.md +++ b/docs/bot_tutorial/building_block_listeners.md @@ -1,6 +1,6 @@ # Listeners -Listeners provide an API to listen to and execute code upon the occurance of specified Discord events. +Listeners provide an API to listen to and execute code upon the occurrence of specified Discord events. ## Listener Basics @@ -28,7 +28,7 @@ To see all the events you can subscribe too, checkout the [gateway events list]( ## Listener Priority -Each listener thats registered comes with a priority. This priority describes how the builtin event emitter will distribute events to your listener. To set a priority you can simply pass the priority kwarg: +Each listener that's registered comes with a priority. This priority describes how the builtin event emitter will distribute events to your listener. To set a priority you can simply pass the priority kwarg: ```py from holster.emitter import Priority @@ -43,6 +43,6 @@ def on_guild_member_add(self, event): | Name | Description | |------|-------------| -| BEFORE | Recieves all events sequentially alongside the emitter. This is the most dangerous priority level, as any executed code will block other events in the emitter from flowing. Blocking within a BEFORE handler can be lethal. | -| SEQUENTIAL | Recieves all events sequentially, but within a seperate greenlet. This priority level can be used for plugins that require sequential events but may block or take a long time to execute their event handler. | -| NONE | This priority provides no guarentees about the ordering of events. Similar to SEQUENTIAL all event handlers are called within a seperate greenlet. | +| BEFORE | Receives all events sequentially alongside the emitter. This is the most dangerous priority level, as any executed code will block other events in the emitter from flowing. Blocking within a BEFORE handler can be lethal. | +| SEQUENTIAL | Receives all events sequentially, but within a separate greenlet. This priority level can be used for plugins that require sequential events but may block or take a long time to execute their event handler. | +| NONE | This priority provides no guarantees about the ordering of events. Similar to SEQUENTIAL all event handlers are called within a separate greenlet. |