diff --git a/analytics/management/commands/check_analytics_state.py b/analytics/management/commands/check_analytics_state.py index ca22f95221..7e30198248 100644 --- a/analytics/management/commands/check_analytics_state.py +++ b/analytics/management/commands/check_analytics_state.py @@ -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.'} diff --git a/zerver/forms.py b/zerver/forms.py index 569bea19dd..9b112eb6dd 100644 --- a/zerver/forms.py +++ b/zerver/forms.py @@ -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. diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index e77ac0775a..02d93b6d21 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -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] diff --git a/zerver/lib/message.py b/zerver/lib/message.py index 980f332fbb..7dc52c8752 100644 --- a/zerver/lib/message.py +++ b/zerver/lib/message.py @@ -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, diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py index 6df9d31716..763a51771d 100644 --- a/zerver/lib/test_classes.py +++ b/zerver/lib/test_classes.py @@ -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 diff --git a/zerver/lib/test_helpers.py b/zerver/lib/test_helpers.py index dee26ffedd..1d571ccf3c 100644 --- a/zerver/lib/test_helpers.py +++ b/zerver/lib/test_helpers.py @@ -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 {} diff --git a/zerver/management/commands/create_default_stream_groups.py b/zerver/management/commands/create_default_stream_groups.py index 1b950b6fc0..9cfe6f6ebe 100644 --- a/zerver/management/commands/create_default_stream_groups.py +++ b/zerver/management/commands/create_default_stream_groups.py @@ -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 diff --git a/zerver/models.py b/zerver/models.py index 8c3a8c1988..57f194834c 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -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: diff --git a/zerver/views/home.py b/zerver/views/home.py index 2da365e49f..64be0d7c17 100644 --- a/zerver/views/home.py +++ b/zerver/views/home.py @@ -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({ diff --git a/zerver/webhooks/bitbucket2/tests.py b/zerver/webhooks/bitbucket2/tests.py index 589e974771..fc044a2ca6 100644 --- a/zerver/webhooks/bitbucket2/tests.py +++ b/zerver/webhooks/bitbucket2/tests.py @@ -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) diff --git a/zerver/webhooks/gitlab/tests.py b/zerver/webhooks/gitlab/tests.py index e9bce0d3ad..1db04d82a5 100644 --- a/zerver/webhooks/gitlab/tests.py +++ b/zerver/webhooks/gitlab/tests.py @@ -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:"