mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
zerver/lib: Use python 3 syntax for typing.
With tweaks by tabbott to fix line spacing.
This commit is contained in:
@@ -9,8 +9,7 @@ from typing import Any, Dict, Optional, Text, List
|
||||
|
||||
from zerver.models import Realm, UserProfile
|
||||
|
||||
def is_integer_string(val):
|
||||
# type: (str) -> bool
|
||||
def is_integer_string(val: str) -> bool:
|
||||
try:
|
||||
int(val)
|
||||
return True
|
||||
@@ -18,8 +17,8 @@ def is_integer_string(val):
|
||||
return False
|
||||
|
||||
class ZulipBaseCommand(BaseCommand):
|
||||
def add_realm_args(self, parser, required=False, help=None):
|
||||
# type: (ArgumentParser, bool, Optional[str]) -> None
|
||||
def add_realm_args(self, parser: ArgumentParser, required: bool=False,
|
||||
help: Optional[str]=None) -> None:
|
||||
if help is None:
|
||||
help = """The numeric or string ID (subdomain) of the Zulip organization to modify.
|
||||
You can use the command list_realms to find ID of the realms in this server."""
|
||||
@@ -31,8 +30,11 @@ You can use the command list_realms to find ID of the realms in this server."""
|
||||
type=str,
|
||||
help=help)
|
||||
|
||||
def add_user_list_args(self, parser, required=False, help=None, all_users_arg=True, all_users_help=None):
|
||||
# type: (ArgumentParser, bool, Optional[str], bool, Optional[str]) -> None
|
||||
def add_user_list_args(self, parser: ArgumentParser,
|
||||
required: bool=False,
|
||||
help: Optional[str]=None,
|
||||
all_users_arg: bool=True,
|
||||
all_users_help: Optional[str]=None) -> None:
|
||||
if help is None:
|
||||
help = 'A comma-separated list of email addresses.'
|
||||
|
||||
@@ -54,8 +56,7 @@ You can use the command list_realms to find ID of the realms in this server."""
|
||||
default=False,
|
||||
help=all_users_help)
|
||||
|
||||
def get_realm(self, options):
|
||||
# type: (Dict[str, Any]) -> Optional[Realm]
|
||||
def get_realm(self, options: Dict[str, Any]) -> Optional[Realm]:
|
||||
val = options["realm_id"]
|
||||
if val is None:
|
||||
return None
|
||||
@@ -71,8 +72,7 @@ You can use the command list_realms to find ID of the realms in this server."""
|
||||
raise CommandError("There is no realm with id '%s'. Aborting." %
|
||||
(options["realm_id"],))
|
||||
|
||||
def get_users(self, options, realm):
|
||||
# type: (Dict[str, Any], Optional[Realm]) -> List[UserProfile]
|
||||
def get_users(self, options: Dict[str, Any], realm: Optional[Realm]) -> List[UserProfile]:
|
||||
if "all_users" in options:
|
||||
all_users = options["all_users"]
|
||||
|
||||
@@ -96,8 +96,7 @@ You can use the command list_realms to find ID of the realms in this server."""
|
||||
user_profiles.append(self.get_user(email, realm))
|
||||
return user_profiles
|
||||
|
||||
def get_user(self, email, realm):
|
||||
# type: (Text, Optional[Realm]) -> UserProfile
|
||||
def get_user(self, email: Text, realm: Optional[Realm]) -> UserProfile:
|
||||
|
||||
# If a realm is specified, try to find the user there, and
|
||||
# throw an error if they don't exist.
|
||||
|
||||
Reference in New Issue
Block a user