mirror of https://github.com/zulip/zulip.git
mypy: Final small migrations to python3.5 annotations in many files.
This commit is contained in:
parent
34db2e59dd
commit
9e1dbde82d
|
@ -29,8 +29,7 @@ class Command(BaseCommand):
|
|||
|
||||
Run as a cron job that runs every hour."""
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# type: (*Any, **Any) -> None
|
||||
def handle(self, *args: Any, **options: Any) -> None:
|
||||
fill_state = self.get_fill_state()
|
||||
status = fill_state['status']
|
||||
message = fill_state['message']
|
||||
|
@ -43,8 +42,7 @@ class Command(BaseCommand):
|
|||
int(time.time()), status, states[status], message))
|
||||
subprocess.check_call(["mv", state_file_tmp, state_file_path])
|
||||
|
||||
def get_fill_state(self):
|
||||
# type: () -> Dict[str, Any]
|
||||
def get_fill_state(self) -> Dict[str, Any]:
|
||||
if not Realm.objects.exists():
|
||||
return {'status': 0, 'message': 'No realms exist, so not checking FillState.'}
|
||||
|
||||
|
|
|
@ -281,8 +281,7 @@ class OurAuthenticationForm(AuthenticationForm):
|
|||
|
||||
return self.cleaned_data
|
||||
|
||||
def add_prefix(self, field_name):
|
||||
# type: (Text) -> Text
|
||||
def add_prefix(self, field_name: Text) -> Text:
|
||||
"""Disable prefix, since Zulip doesn't use this Django forms feature
|
||||
(and django-two-factor does use it), and we'd like both to be
|
||||
happy with this form.
|
||||
|
|
|
@ -4534,8 +4534,9 @@ def do_update_user_group_description(user_group: UserGroup, description: Text) -
|
|||
user_group.save(update_fields=['description'])
|
||||
do_send_user_group_update_event(user_group, dict(description=description))
|
||||
|
||||
def do_update_outgoing_webhook_service(bot_profile, service_interface, service_payload_url):
|
||||
# type: (UserProfile, int, Text) -> None
|
||||
def do_update_outgoing_webhook_service(bot_profile: UserProfile,
|
||||
service_interface: int,
|
||||
service_payload_url: Text) -> None:
|
||||
# TODO: First service is chosen because currently one bot can only have one service.
|
||||
# Update this once multiple services are supported.
|
||||
service = get_bot_services(bot_profile.id)[0]
|
||||
|
|
|
@ -264,24 +264,23 @@ class MessageDict:
|
|||
|
||||
@staticmethod
|
||||
def build_message_dict(
|
||||
message,
|
||||
message_id,
|
||||
last_edit_time,
|
||||
edit_history,
|
||||
content,
|
||||
subject,
|
||||
pub_date,
|
||||
rendered_content,
|
||||
rendered_content_version,
|
||||
sender_id,
|
||||
sender_realm_id,
|
||||
sending_client_name,
|
||||
recipient_id,
|
||||
recipient_type,
|
||||
recipient_type_id,
|
||||
reactions
|
||||
):
|
||||
# type: (Optional[Message], int, Optional[datetime.datetime], Optional[Text], Text, Text, datetime.datetime, Optional[Text], Optional[int], int, int, Text, int, int, int, List[Dict[str, Any]]) -> Dict[str, Any]
|
||||
message: Optional[Message],
|
||||
message_id: int,
|
||||
last_edit_time: Optional[datetime.datetime],
|
||||
edit_history: Optional[Text],
|
||||
content: Text,
|
||||
subject: Text,
|
||||
pub_date: datetime.datetime,
|
||||
rendered_content: Optional[Text],
|
||||
rendered_content_version: Optional[int],
|
||||
sender_id: int,
|
||||
sender_realm_id: int,
|
||||
sending_client_name: Text,
|
||||
recipient_id: int,
|
||||
recipient_type: int,
|
||||
recipient_type_id: int,
|
||||
reactions: List[Dict[str, Any]]
|
||||
) -> Dict[str, Any]:
|
||||
|
||||
obj = dict(
|
||||
id = message_id,
|
||||
|
|
|
@ -116,8 +116,7 @@ class ZulipTestCase(TestCase):
|
|||
return django_client.patch(url, encoded, **kwargs)
|
||||
|
||||
@instrument_url
|
||||
def client_patch_multipart(self, url, info={}, **kwargs):
|
||||
# type: (Text, Dict[str, Any], **Any) -> HttpResponse
|
||||
def client_patch_multipart(self, url: Text, info: Dict[str, Any]={}, **kwargs: Any) -> HttpResponse:
|
||||
"""
|
||||
Use this for patch requests that have file uploads or
|
||||
that need some sort of multi-part content. In the future
|
||||
|
|
|
@ -115,8 +115,7 @@ def simulated_empty_cache() -> Generator[
|
|||
cache_queries.append(('get', key, cache_name))
|
||||
return None
|
||||
|
||||
def my_cache_get_many(keys, cache_name=None): # nocoverage -- simulated code doesn't use this
|
||||
# type: (List[Text], Optional[str]) -> Dict[Text, Any]
|
||||
def my_cache_get_many(keys: List[Text], cache_name: Optional[str]=None) -> Dict[Text, Any]: # nocoverage -- simulated code doesn't use this
|
||||
cache_queries.append(('getmany', keys, cache_name))
|
||||
return {}
|
||||
|
||||
|
|
|
@ -13,8 +13,7 @@ Create default stream groups which the users can choose during sign up.
|
|||
./manage.py create_default_stream_groups -s gsoc-1,gsoc-2,gsoc-3 -d "Google summer of code" -r zulip
|
||||
"""
|
||||
|
||||
def add_arguments(self, parser):
|
||||
# type: (ArgumentParser) -> None
|
||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||
self.add_realm_args(parser, True)
|
||||
|
||||
parser.add_argument(
|
||||
|
@ -40,8 +39,7 @@ Create default stream groups which the users can choose during sign up.
|
|||
required=True,
|
||||
help='A comma-separated list of stream names.')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
# type: (*Any, **Any) -> None
|
||||
def handle(self, *args: Any, **options: Any) -> None:
|
||||
realm = self.get_realm(options)
|
||||
assert realm is not None # Should be ensured by parser
|
||||
|
||||
|
|
|
@ -777,8 +777,7 @@ class UserProfile(AbstractBaseUser, PermissionsMixin):
|
|||
return self.is_bot and self.bot_type in UserProfile.SERVICE_BOT_TYPES
|
||||
|
||||
@property
|
||||
def allowed_bot_types(self):
|
||||
# type: () -> List[int]
|
||||
def allowed_bot_types(self) -> List[int]:
|
||||
allowed_bot_types = []
|
||||
if self.is_realm_admin or \
|
||||
not self.realm.bot_creation_policy == Realm.BOT_CREATION_LIMIT_GENERIC_BOTS:
|
||||
|
|
|
@ -64,8 +64,7 @@ def sent_time_in_epoch_seconds(user_message: Optional[UserMessage]) -> Optional[
|
|||
# Return the epoch seconds in UTC.
|
||||
return calendar.timegm(user_message.message.pub_date.utctimetuple())
|
||||
|
||||
def get_bot_types(user_profile):
|
||||
# type: (UserProfile) -> List[Dict[Text, object]]
|
||||
def get_bot_types(user_profile: UserProfile) -> List[Dict[Text, object]]:
|
||||
bot_types = []
|
||||
for type_id, name in UserProfile.BOT_TYPES.items():
|
||||
bot_types.append({
|
||||
|
|
|
@ -270,8 +270,8 @@ class Bitbucket2HookTests(WebhookTestCase):
|
|||
self.assert_json_success(result)
|
||||
|
||||
@patch('zerver.webhooks.bitbucket2.view.check_send_stream_message')
|
||||
def test_bitbucket2_on_push_without_changes_ignore(self, check_send_stream_message_mock):
|
||||
# type: (MagicMock) -> None
|
||||
def test_bitbucket2_on_push_without_changes_ignore(
|
||||
self, check_send_stream_message_mock: MagicMock) -> None:
|
||||
payload = self.get_body('push_without_changes')
|
||||
result = self.client_post(self.url, payload, content_type="application/json")
|
||||
self.assertFalse(check_send_stream_message_mock.called)
|
||||
|
|
|
@ -407,8 +407,7 @@ class GitlabHookTests(WebhookTestCase):
|
|||
HTTP_X_GITLAB_EVENT="Pipeline Hook"
|
||||
)
|
||||
|
||||
def test_issue_type_test_payload(self):
|
||||
# type: () -> None
|
||||
def test_issue_type_test_payload(self) -> None:
|
||||
expected_subject = u'public-repo'
|
||||
expected_message = u"Webhook for **public-repo** has been configured successfully! :tada:"
|
||||
|
||||
|
|
Loading…
Reference in New Issue