diff --git a/scripts/setup/generate_secrets.py b/scripts/setup/generate_secrets.py index 1c49548ead..41b04a88bc 100755 --- a/scripts/setup/generate_secrets.py +++ b/scripts/setup/generate_secrets.py @@ -47,7 +47,7 @@ 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 {} @@ -55,7 +55,7 @@ def get_old_conf(output_filename): 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 diff --git a/tools/documentation_crawler/documentation_crawler/spiders/check_documentation.py b/tools/documentation_crawler/documentation_crawler/spiders/check_documentation.py index 0a294c7d32..ca55c5efe0 100755 --- a/tools/documentation_crawler/documentation_crawler/spiders/check_documentation.py +++ b/tools/documentation_crawler/documentation_crawler/spiders/check_documentation.py @@ -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() diff --git a/tools/documentation_crawler/documentation_crawler/spiders/common/spiders.py b/tools/documentation_crawler/documentation_crawler/spiders/common/spiders.py index d54b556b73..c21122828e 100644 --- a/tools/documentation_crawler/documentation_crawler/spiders/common/spiders.py +++ b/tools/documentation_crawler/documentation_crawler/spiders/common/spiders.py @@ -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') diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index bc2e9c8206..2c072e01ed 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -82,7 +82,7 @@ from zerver.lib.session_user import get_session_user 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 diff --git a/zerver/lib/events.py b/zerver/lib/events.py index 5204ae7355..d70de6d96c 100644 --- a/zerver/lib/events.py +++ b/zerver/lib/events.py @@ -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 diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.py index 09143c9da3..3f8d1f79dd 100644 --- a/zerver/tornado/event_queue.py +++ b/zerver/tornado/event_queue.py @@ -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 diff --git a/zerver/webhooks/github/view.py b/zerver/webhooks/github/view.py index 8f9bd77940..b07eb31274 100644 --- a/zerver/webhooks/github/view.py +++ b/zerver/webhooks/github/view.py @@ -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 diff --git a/zerver/webhooks/gitlab/view.py b/zerver/webhooks/gitlab/view.py index 43755701f5..cb8db602d5 100644 --- a/zerver/webhooks/gitlab/view.py +++ b/zerver/webhooks/gitlab/view.py @@ -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