Skip to content

Commit

Permalink
Fix more errors caught by mypy 0.501.
Browse files Browse the repository at this point in the history
Another set of relatively easy to review changes.
  • Loading branch information
rishig committed Mar 3, 2017
1 parent 28d3af0 commit 2bbfdee
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions scripts/setup/generate_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ def generate_django_secretkey():
return get_random_string(50, chars)

def get_old_conf(output_filename):
# type: (Text) -> Dict[str, Text]
# type: (str) -> Dict[str, Text]
if not os.path.exists(output_filename):
return {}

secrets_file = six.moves.configparser.RawConfigParser() # type: ignore # https://github.com/python/typeshed/issues/307
secrets_file.read(output_filename)

def get_secret(key):
# type: (Text) -> Optional[Text]
# type: (str) -> Optional[Text]
if secrets_file.has_option('secrets', key):
return secrets_file.get('secrets', key)
return None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ def get_start_url():
class DocumentationSpider(BaseDocumentationSpider):
name = "documentation_crawler"
deny_domains = ['localhost:9991']
deny = '\_sources\/.*\.txt'
deny = ['\_sources\/.*\.txt']
start_urls = get_start_url()
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BaseDocumentationSpider(scrapy.Spider):
# Exclude domain address.
deny_domains = [] # type: List[str]
start_urls = [] # type: List[str]
deny = () # type: Tuple
deny = [] # type: List[str]
file_extensions = ['.' + ext for ext in IGNORED_EXTENSIONS] # type: List[str]
tags = ('a', 'area', 'img')
attrs = ('href', 'src')
Expand Down
2 changes: 1 addition & 1 deletion zerver/lib/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
from zerver.lib.upload import attachment_url_re, attachment_url_to_path_id, \
claim_attachment, delete_message_image
from zerver.lib.str_utils import NonBinaryStr, force_str
from zerver.tornado.event_queue import request_event_queue, get_user_events, send_event
from zerver.tornado.event_queue import request_event_queue, send_event

import DNS
import ujson
Expand Down
2 changes: 1 addition & 1 deletion zerver/lib/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def do_events_register(user_profile, user_client, apply_markdown=True,
# Apply events that came in while we were fetching initial data
events = get_user_events(user_profile, queue_id, -1)
apply_events(ret, events, user_profile, include_subscribers=include_subscribers)
if events:
if len(events) > 0:
ret['last_event_id'] = events[-1]['id']
else:
ret['last_event_id'] = -1
Expand Down
2 changes: 1 addition & 1 deletion zerver/tornado/event_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def get_user_events(user_profile, queue_id, last_event_id):
resp.raise_for_status()

return extract_json_response(resp)['events']

return []

# Send email notifications to idle users
# after they are idle for 1 hour
Expand Down
3 changes: 2 additions & 1 deletion zerver/webhooks/github/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ def get_pull_request_or_issue_action(payload):
return 'synchronized' if payload['action'] == 'synchronize' else payload['action']

def get_pull_request_or_issue_assignee(object_payload):
# type: (Mapping[Text, Any]) -> Text
# type: (Mapping[Text, Any]) -> Optional[Text]
assignee_dict = object_payload.get('assignee')
if assignee_dict:
return assignee_dict.get('login')
return None

def get_pull_request_or_issue_subject(repository, payload_object, type):
# type: (Mapping[Text, Any], Mapping[Text, Any], Text) -> Text
Expand Down
3 changes: 2 additions & 1 deletion zerver/webhooks/gitlab/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ def get_merge_request_open_or_updated_body(payload, action):
)

def get_objects_assignee(payload):
# type: (Dict[str, Any]) -> Text
# type: (Dict[str, Any]) -> Optional[Text]
assignee_object = payload.get('assignee')
if assignee_object:
return assignee_object.get('name')
return None

def get_commented_commit_event_body(payload):
# type: (Dict[str, Any]) -> Text
Expand Down

0 comments on commit 2bbfdee

Please sign in to comment.