mypy: Annotate api/integrations/twitter/twitter-search-bot

This commit is contained in:
Sampriti Panda 2017-01-01 02:01:28 +05:30 committed by showell
parent a5e45f4213
commit 246ac7cadc
2 changed files with 5 additions and 5 deletions

View File

@ -27,13 +27,14 @@ from __future__ import print_function
import os import os
import sys import sys
import optparse import optparse
import six.moves.configparser from six.moves.configparser import ConfigParser, NoSectionError, NoOptionError
import zulip import zulip
VERSION = "0.9" VERSION = "0.9"
CONFIGFILE = os.path.expanduser("~/.zulip_twitterrc") CONFIGFILE = os.path.expanduser("~/.zulip_twitterrc")
def write_config(config, since_id): def write_config(config, since_id):
# type: (ConfigParser, int) -> None
if 'search' not in config.sections(): if 'search' not in config.sections():
config.add_section('search') config.add_section('search')
config.set('search', 'since_id', since_id) config.set('search', 'since_id', since_id)
@ -111,14 +112,14 @@ if not opts.search_terms:
parser.error('You must specify a search term.') parser.error('You must specify a search term.')
try: try:
config = six.moves.configparser.ConfigParser() config = ConfigParser()
config.read(CONFIGFILE) config.read(CONFIGFILE)
consumer_key = config.get('twitter', 'consumer_key') consumer_key = config.get('twitter', 'consumer_key')
consumer_secret = config.get('twitter', 'consumer_secret') consumer_secret = config.get('twitter', 'consumer_secret')
access_token_key = config.get('twitter', 'access_token_key') access_token_key = config.get('twitter', 'access_token_key')
access_token_secret = config.get('twitter', 'access_token_secret') access_token_secret = config.get('twitter', 'access_token_secret')
except (six.moves.configparser.NoSectionError, six.moves.configparser.NoOptionError): except (NoSectionError, NoOptionError):
parser.error("Please provide a ~/.zulip_twitterrc") parser.error("Please provide a ~/.zulip_twitterrc")
if not (consumer_key and consumer_secret and access_token_key and access_token_secret): if not (consumer_key and consumer_secret and access_token_key and access_token_secret):
@ -126,7 +127,7 @@ if not (consumer_key and consumer_secret and access_token_key and access_token_s
try: try:
since_id = config.getint('search', 'since_id') since_id = config.getint('search', 'since_id')
except (six.moves.configparser.NoOptionError, six.moves.configparser.NoSectionError): except (NoOptionError, NoSectionError):
since_id = 0 since_id = 0
try: try:

View File

@ -30,7 +30,6 @@ api/integrations/basecamp/zulip_basecamp_mirror
api/integrations/codebase/zulip_codebase_mirror api/integrations/codebase/zulip_codebase_mirror
api/integrations/git/post-receive api/integrations/git/post-receive
api/integrations/rss/rss-bot api/integrations/rss/rss-bot
api/integrations/twitter/twitter-search-bot
tools/deprecated/iframe-bot/show-last-messages tools/deprecated/iframe-bot/show-last-messages
tools/deprecated/inject-messages/inject-messages tools/deprecated/inject-messages/inject-messages
zproject/settings.py zproject/settings.py