Skip to content

Commit

Permalink
Use Iterable instead of Sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
oklahomer committed Nov 8, 2015
1 parent 2199d20 commit 3cc86f6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions sarah/bot/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from functools import wraps

from apscheduler.schedulers.background import BackgroundScheduler
from typing import Sequence, Optional, Callable, Union
from typing import Optional, Callable, Union, Iterable

from sarah.bot.types import PluginConfig, AnyFunction, CommandFunction
from sarah.bot.values import Command, CommandMessage, UserContext, \
Expand All @@ -25,7 +25,7 @@ class Base(object, metaclass=abc.ABCMeta):
__instances = {}

def __init__(self,
plugins: Sequence[PluginConfig] = None,
plugins: Iterable[PluginConfig] = None,
max_workers: Optional[int] = None) -> None:
if not plugins:
plugins = ()
Expand Down Expand Up @@ -247,7 +247,7 @@ def wrapped_function(*args, **kwargs) -> str:

return wrapper

def add_schedule_jobs(self, commands: Sequence[ScheduledCommand]) -> None:
def add_schedule_jobs(self, commands: Iterable[ScheduledCommand]) -> None:
for command in commands:
# self.add_schedule_job(command)
job_function = self.generate_schedule_job(command)
Expand Down
8 changes: 4 additions & 4 deletions sarah/bot/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from concurrent.futures import Future

import requests
from typing import Optional, Dict, Sequence, Callable
from typing import Optional, Dict, Callable, Iterable
from websocket import WebSocketApp

from sarah import ValueObject
Expand Down Expand Up @@ -85,7 +85,7 @@ def __init__(self,
author_name: str = None,
author_link: str = None,
author_icon: str = None,
fields: Sequence[AttachmentField] = None,
fields: Iterable[AttachmentField] = None,
image_url: str = None,
thumb_url: str = None,
pretext: str = None,
Expand Down Expand Up @@ -118,7 +118,7 @@ def __init__(self,
unfurl_media: bool = False,
icon_url: str = None,
icon_emoji: str = None,
attachments: Sequence[MessageAttachment] = None):
attachments: Iterable[MessageAttachment] = None):
pass

def __str__(self) -> str:
Expand Down Expand Up @@ -148,7 +148,7 @@ def to_request_params(self) -> Dict:
class Slack(Base):
def __init__(self,
token: str = '',
plugins: Sequence[PluginConfig] = None,
plugins: Iterable[PluginConfig] = None,
max_workers: int = None) -> None:

super().__init__(plugins=plugins, max_workers=max_workers)
Expand Down
6 changes: 3 additions & 3 deletions sarah/bot/values/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import abc
import re

from typing import Union, Pattern, AnyStr, Callable, Sequence, Dict
from typing import Union, Pattern, AnyStr, Callable, Dict, Iterable

from sarah import ValueObject
from sarah.bot.types import CommandFunction, CommandConfig
Expand Down Expand Up @@ -37,7 +37,7 @@ class UserContext(ValueObject):
def __init__(self,
message: Union[str, RichMessage],
help_message: str,
input_options: Sequence[InputOption]) -> None:
input_options: Iterable[InputOption]) -> None:
pass

def __str__(self):
Expand All @@ -52,7 +52,7 @@ def help_message(self) -> str:
return self['help_message']

@property
def input_options(self) -> Sequence[InputOption]:
def input_options(self) -> Iterable[InputOption]:
return self['input_options']


Expand Down
6 changes: 3 additions & 3 deletions sarah/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from multiprocessing import Process

import yaml
from typing import Dict, Sequence
from typing import Dict, Iterable

from sarah.bot.hipchat import HipChat
from sarah.bot.slack import Slack
Expand All @@ -15,7 +15,7 @@

class Sarah(object):
def __init__(self,
config_paths: Sequence[Path]) -> None:
config_paths: Iterable[Path]) -> None:

self.config = self.load_config(config_paths)

Expand All @@ -33,7 +33,7 @@ def start(self) -> None:
slack_process.start()

@staticmethod
def load_config(paths: Sequence[Path]) -> Dict:
def load_config(paths: Iterable[Path]) -> Dict:
config = {}

if not paths:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_value_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TestOverride(object):
class MyValueWithInit(ValueObject):
def __init__(self,
pattern: Union[Pattern, AnyStr] = None,
key1="spam"):
key1="spam") -> None:
if isinstance(pattern, str):
self['pattern'] = re.compile(pattern)

Expand Down

0 comments on commit 3cc86f6

Please sign in to comment.