mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	Fix more errors caught by mypy 0.501.
Another set of relatively easy to review changes.
This commit is contained in:
		@@ -47,7 +47,7 @@ def generate_django_secretkey():
 | 
				
			|||||||
    return get_random_string(50, chars)
 | 
					    return get_random_string(50, chars)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_old_conf(output_filename):
 | 
					def get_old_conf(output_filename):
 | 
				
			||||||
    # type: (Text) -> Dict[str, Text]
 | 
					    # type: (str) -> Dict[str, Text]
 | 
				
			||||||
    if not os.path.exists(output_filename):
 | 
					    if not os.path.exists(output_filename):
 | 
				
			||||||
        return {}
 | 
					        return {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -55,7 +55,7 @@ def get_old_conf(output_filename):
 | 
				
			|||||||
    secrets_file.read(output_filename)
 | 
					    secrets_file.read(output_filename)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_secret(key):
 | 
					    def get_secret(key):
 | 
				
			||||||
        # type: (Text) -> Optional[Text]
 | 
					        # type: (str) -> Optional[Text]
 | 
				
			||||||
        if secrets_file.has_option('secrets', key):
 | 
					        if secrets_file.has_option('secrets', key):
 | 
				
			||||||
            return secrets_file.get('secrets', key)
 | 
					            return secrets_file.get('secrets', key)
 | 
				
			||||||
        return None
 | 
					        return None
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,5 +23,5 @@ def get_start_url():
 | 
				
			|||||||
class DocumentationSpider(BaseDocumentationSpider):
 | 
					class DocumentationSpider(BaseDocumentationSpider):
 | 
				
			||||||
    name = "documentation_crawler"
 | 
					    name = "documentation_crawler"
 | 
				
			||||||
    deny_domains = ['localhost:9991']
 | 
					    deny_domains = ['localhost:9991']
 | 
				
			||||||
    deny = '\_sources\/.*\.txt'
 | 
					    deny = ['\_sources\/.*\.txt']
 | 
				
			||||||
    start_urls = get_start_url()
 | 
					    start_urls = get_start_url()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,7 +18,7 @@ class BaseDocumentationSpider(scrapy.Spider):
 | 
				
			|||||||
    # Exclude domain address.
 | 
					    # Exclude domain address.
 | 
				
			||||||
    deny_domains = []  # type: List[str]
 | 
					    deny_domains = []  # type: List[str]
 | 
				
			||||||
    start_urls = []  # 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]
 | 
					    file_extensions = ['.' + ext for ext in IGNORED_EXTENSIONS]  # type: List[str]
 | 
				
			||||||
    tags = ('a', 'area', 'img')
 | 
					    tags = ('a', 'area', 'img')
 | 
				
			||||||
    attrs = ('href', 'src')
 | 
					    attrs = ('href', 'src')
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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, \
 | 
					from zerver.lib.upload import attachment_url_re, attachment_url_to_path_id, \
 | 
				
			||||||
    claim_attachment, delete_message_image
 | 
					    claim_attachment, delete_message_image
 | 
				
			||||||
from zerver.lib.str_utils import NonBinaryStr, force_str
 | 
					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 DNS
 | 
				
			||||||
import ujson
 | 
					import ujson
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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
 | 
					    # Apply events that came in while we were fetching initial data
 | 
				
			||||||
    events = get_user_events(user_profile, queue_id, -1)
 | 
					    events = get_user_events(user_profile, queue_id, -1)
 | 
				
			||||||
    apply_events(ret, events, user_profile, include_subscribers=include_subscribers)
 | 
					    apply_events(ret, events, user_profile, include_subscribers=include_subscribers)
 | 
				
			||||||
    if events:
 | 
					    if len(events) > 0:
 | 
				
			||||||
        ret['last_event_id'] = events[-1]['id']
 | 
					        ret['last_event_id'] = events[-1]['id']
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        ret['last_event_id'] = -1
 | 
					        ret['last_event_id'] = -1
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -606,7 +606,7 @@ def get_user_events(user_profile, queue_id, last_event_id):
 | 
				
			|||||||
        resp.raise_for_status()
 | 
					        resp.raise_for_status()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return extract_json_response(resp)['events']
 | 
					        return extract_json_response(resp)['events']
 | 
				
			||||||
 | 
					    return []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Send email notifications to idle users
 | 
					# Send email notifications to idle users
 | 
				
			||||||
# after they are idle for 1 hour
 | 
					# after they are idle for 1 hour
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -92,10 +92,11 @@ def get_pull_request_or_issue_action(payload):
 | 
				
			|||||||
    return 'synchronized' if payload['action'] == 'synchronize' else payload['action']
 | 
					    return 'synchronized' if payload['action'] == 'synchronize' else payload['action']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_pull_request_or_issue_assignee(object_payload):
 | 
					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')
 | 
					    assignee_dict = object_payload.get('assignee')
 | 
				
			||||||
    if assignee_dict:
 | 
					    if assignee_dict:
 | 
				
			||||||
        return assignee_dict.get('login')
 | 
					        return assignee_dict.get('login')
 | 
				
			||||||
 | 
					    return None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_pull_request_or_issue_subject(repository, payload_object, type):
 | 
					def get_pull_request_or_issue_subject(repository, payload_object, type):
 | 
				
			||||||
    # type: (Mapping[Text, Any], Mapping[Text, Any], Text) -> Text
 | 
					    # type: (Mapping[Text, Any], Mapping[Text, Any], Text) -> Text
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -115,10 +115,11 @@ def get_merge_request_open_or_updated_body(payload, action):
 | 
				
			|||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_objects_assignee(payload):
 | 
					def get_objects_assignee(payload):
 | 
				
			||||||
    # type: (Dict[str, Any]) -> Text
 | 
					    # type: (Dict[str, Any]) -> Optional[Text]
 | 
				
			||||||
    assignee_object = payload.get('assignee')
 | 
					    assignee_object = payload.get('assignee')
 | 
				
			||||||
    if assignee_object:
 | 
					    if assignee_object:
 | 
				
			||||||
        return assignee_object.get('name')
 | 
					        return assignee_object.get('name')
 | 
				
			||||||
 | 
					    return None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_commented_commit_event_body(payload):
 | 
					def get_commented_commit_event_body(payload):
 | 
				
			||||||
    # type: (Dict[str, Any]) -> Text
 | 
					    # type: (Dict[str, Any]) -> Text
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user