mypy: Add assertions of get_realm results when parser requires realm.

This commit is contained in:
neiljp (Neil Pilgrim)
2017-09-25 16:25:39 -07:00
committed by Greg Price
parent 7737326cf0
commit ab4cbf81f0
15 changed files with 20 additions and 0 deletions

View File

@@ -27,6 +27,8 @@ class Command(ZulipBaseCommand):
def handle(self, **options):
# type: (**Any) -> None
realm = self.get_realm(options)
assert realm is not None # Should be ensured by parser
user_profiles = self.get_users(options, realm)
stream_names = set([stream.strip() for stream in options["streams"].split(",")])

View File

@@ -25,6 +25,8 @@ the command."""
def handle(self, *args, **options):
# type: (*Any, **str) -> None
realm = self.get_realm(options)
assert realm is not None # Should be ensured by parser
encoding = sys.getfilesystemencoding()
stream_name = options['stream_name']
create_stream_if_needed(realm, force_text(stream_name, encoding))

View File

@@ -60,6 +60,8 @@ Omit both <email> and <full name> for interactive user creation.
raise CommandError("""You must confirm that this user has accepted the
Terms of Service by passing --this-user-has-accepted-the-tos.""")
realm = self.get_realm(options)
assert realm is not None # Should be ensured by parser
try:
email = options['email']
full_name = options['full_name']

View File

@@ -18,6 +18,8 @@ class Command(ZulipBaseCommand):
def handle(self, *args, **options):
# type: (*Any, **str) -> None
realm = self.get_realm(options)
assert realm is not None # Should be ensured by parser
if realm.deactivated:
print("The realm", options["realm_id"], "is already deactivated.")
exit(0)

View File

@@ -108,6 +108,8 @@ class Command(ZulipBaseCommand):
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
realm = self.get_realm(options)
assert realm is not None # Should be ensured by parser
output_dir = options["output_dir"]
if output_dir is None:
output_dir = tempfile.mkdtemp(prefix="/tmp/zulip-export-")

View File

@@ -27,6 +27,7 @@ class Command(ZulipBaseCommand):
# type: (*Any, **Any) -> None
duplicates = False
realm = self.get_realm(options)
assert realm is not None # Should be ensured by parser
if not options['emails']:
self.print_help("./manage.py", "generate_invite_links")

View File

@@ -33,6 +33,7 @@ class Command(ZulipBaseCommand):
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
realm = self.get_realm(options)
assert realm is not None # Should be ensured by parser
streams = []
if options["streams"]:

View File

@@ -37,6 +37,7 @@ class Command(ZulipBaseCommand):
def handle(self, *args, **options):
# type: (*Any, **str) -> None
realm = self.get_realm(options)
assert realm is not None # Should be ensured by parser
stream_to_keep = get_stream(options["stream_to_keep"], realm)
stream_to_destroy = get_stream(options["stream_to_destroy"], realm)

View File

@@ -18,6 +18,7 @@ class Command(ZulipBaseCommand):
def handle(self, *args, **options):
# type: (*Any, **str) -> None
realm = self.get_realm(options)
assert realm is not None # Should be ensured by parser
if not realm.deactivated:
print("Realm", options["realm_id"], "is already active.")
exit(0)

View File

@@ -33,6 +33,7 @@ class Command(ZulipBaseCommand):
def handle(self, *args, **options):
# type: (*Any, **str) -> None
realm = self.get_realm(options)
assert realm is not None # Should be ensured by parser
if options["op"] == "show":
print("Domains for %s:" % (realm.string_id,))
for realm_domain in get_realm_domains(realm):

View File

@@ -43,6 +43,7 @@ Example: ./manage.py realm_emoji --realm=zulip.com --op=show
def handle(self, *args, **options):
# type: (*Any, **str) -> None
realm = self.get_realm(options)
assert realm is not None # Should be ensured by parser
if options["op"] == "show":
for name, url in six.iteritems(realm.get_emoji()):
print(name, url)

View File

@@ -40,6 +40,7 @@ Example: ./manage.py realm_filters --realm=zulip --op=show
def handle(self, *args, **options):
# type: (*Any, **str) -> None
realm = self.get_realm(options)
assert realm is not None # Should be ensured by parser
if options["op"] == "show":
print("%s: %s" % (realm.string_id, all_realm_filters().get(realm.id, [])))
sys.exit(0)

View File

@@ -26,6 +26,7 @@ class Command(ZulipBaseCommand):
def handle(self, **options):
# type: (**Any) -> None
realm = self.get_realm(options)
assert realm is not None # Should be ensured by parser
user_profiles = self.get_users(options, realm)
stream_name = options["stream"].strip()
stream = get_stream(stream_name, realm)

View File

@@ -26,6 +26,7 @@ class Command(ZulipBaseCommand):
def handle(self, *args, **options):
# type: (*Any, **str) -> None
realm = self.get_realm(options)
assert realm is not None # Should be ensured by parser
old_name = options['old_name']
new_name = options['new_name']
encoding = sys.getfilesystemencoding()

View File

@@ -47,6 +47,7 @@ For example:
with `--streams=`).", file=sys.stderr)
exit(1)
realm = self.get_realm(options)
assert realm is not None # Should be ensured by parser
stream_dict = {
stream.strip(): {"description": stream.strip(), "invite_only": False}