mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 04:23:46 +00:00
mypy: Add assertions of get_realm results when parser requires realm.
This commit is contained in:
committed by
Greg Price
parent
7737326cf0
commit
ab4cbf81f0
@@ -27,6 +27,8 @@ class Command(ZulipBaseCommand):
|
|||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
# type: (**Any) -> None
|
# type: (**Any) -> None
|
||||||
realm = self.get_realm(options)
|
realm = self.get_realm(options)
|
||||||
|
assert realm is not None # Should be ensured by parser
|
||||||
|
|
||||||
user_profiles = self.get_users(options, realm)
|
user_profiles = self.get_users(options, realm)
|
||||||
stream_names = set([stream.strip() for stream in options["streams"].split(",")])
|
stream_names = set([stream.strip() for stream in options["streams"].split(",")])
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ the command."""
|
|||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
# type: (*Any, **str) -> None
|
# type: (*Any, **str) -> None
|
||||||
realm = self.get_realm(options)
|
realm = self.get_realm(options)
|
||||||
|
assert realm is not None # Should be ensured by parser
|
||||||
|
|
||||||
encoding = sys.getfilesystemencoding()
|
encoding = sys.getfilesystemencoding()
|
||||||
stream_name = options['stream_name']
|
stream_name = options['stream_name']
|
||||||
create_stream_if_needed(realm, force_text(stream_name, encoding))
|
create_stream_if_needed(realm, force_text(stream_name, encoding))
|
||||||
|
|||||||
@@ -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
|
raise CommandError("""You must confirm that this user has accepted the
|
||||||
Terms of Service by passing --this-user-has-accepted-the-tos.""")
|
Terms of Service by passing --this-user-has-accepted-the-tos.""")
|
||||||
realm = self.get_realm(options)
|
realm = self.get_realm(options)
|
||||||
|
assert realm is not None # Should be ensured by parser
|
||||||
|
|
||||||
try:
|
try:
|
||||||
email = options['email']
|
email = options['email']
|
||||||
full_name = options['full_name']
|
full_name = options['full_name']
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ class Command(ZulipBaseCommand):
|
|||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
# type: (*Any, **str) -> None
|
# type: (*Any, **str) -> None
|
||||||
realm = self.get_realm(options)
|
realm = self.get_realm(options)
|
||||||
|
assert realm is not None # Should be ensured by parser
|
||||||
|
|
||||||
if realm.deactivated:
|
if realm.deactivated:
|
||||||
print("The realm", options["realm_id"], "is already deactivated.")
|
print("The realm", options["realm_id"], "is already deactivated.")
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|||||||
@@ -108,6 +108,8 @@ class Command(ZulipBaseCommand):
|
|||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
# type: (*Any, **Any) -> None
|
# type: (*Any, **Any) -> None
|
||||||
realm = self.get_realm(options)
|
realm = self.get_realm(options)
|
||||||
|
assert realm is not None # Should be ensured by parser
|
||||||
|
|
||||||
output_dir = options["output_dir"]
|
output_dir = options["output_dir"]
|
||||||
if output_dir is None:
|
if output_dir is None:
|
||||||
output_dir = tempfile.mkdtemp(prefix="/tmp/zulip-export-")
|
output_dir = tempfile.mkdtemp(prefix="/tmp/zulip-export-")
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class Command(ZulipBaseCommand):
|
|||||||
# type: (*Any, **Any) -> None
|
# type: (*Any, **Any) -> None
|
||||||
duplicates = False
|
duplicates = False
|
||||||
realm = self.get_realm(options)
|
realm = self.get_realm(options)
|
||||||
|
assert realm is not None # Should be ensured by parser
|
||||||
|
|
||||||
if not options['emails']:
|
if not options['emails']:
|
||||||
self.print_help("./manage.py", "generate_invite_links")
|
self.print_help("./manage.py", "generate_invite_links")
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class Command(ZulipBaseCommand):
|
|||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
# type: (*Any, **Any) -> None
|
# type: (*Any, **Any) -> None
|
||||||
realm = self.get_realm(options)
|
realm = self.get_realm(options)
|
||||||
|
assert realm is not None # Should be ensured by parser
|
||||||
|
|
||||||
streams = []
|
streams = []
|
||||||
if options["streams"]:
|
if options["streams"]:
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ class Command(ZulipBaseCommand):
|
|||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
# type: (*Any, **str) -> None
|
# type: (*Any, **str) -> None
|
||||||
realm = self.get_realm(options)
|
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_keep = get_stream(options["stream_to_keep"], realm)
|
||||||
stream_to_destroy = get_stream(options["stream_to_destroy"], realm)
|
stream_to_destroy = get_stream(options["stream_to_destroy"], realm)
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class Command(ZulipBaseCommand):
|
|||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
# type: (*Any, **str) -> None
|
# type: (*Any, **str) -> None
|
||||||
realm = self.get_realm(options)
|
realm = self.get_realm(options)
|
||||||
|
assert realm is not None # Should be ensured by parser
|
||||||
if not realm.deactivated:
|
if not realm.deactivated:
|
||||||
print("Realm", options["realm_id"], "is already active.")
|
print("Realm", options["realm_id"], "is already active.")
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class Command(ZulipBaseCommand):
|
|||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
# type: (*Any, **str) -> None
|
# type: (*Any, **str) -> None
|
||||||
realm = self.get_realm(options)
|
realm = self.get_realm(options)
|
||||||
|
assert realm is not None # Should be ensured by parser
|
||||||
if options["op"] == "show":
|
if options["op"] == "show":
|
||||||
print("Domains for %s:" % (realm.string_id,))
|
print("Domains for %s:" % (realm.string_id,))
|
||||||
for realm_domain in get_realm_domains(realm):
|
for realm_domain in get_realm_domains(realm):
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ Example: ./manage.py realm_emoji --realm=zulip.com --op=show
|
|||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
# type: (*Any, **str) -> None
|
# type: (*Any, **str) -> None
|
||||||
realm = self.get_realm(options)
|
realm = self.get_realm(options)
|
||||||
|
assert realm is not None # Should be ensured by parser
|
||||||
if options["op"] == "show":
|
if options["op"] == "show":
|
||||||
for name, url in six.iteritems(realm.get_emoji()):
|
for name, url in six.iteritems(realm.get_emoji()):
|
||||||
print(name, url)
|
print(name, url)
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ Example: ./manage.py realm_filters --realm=zulip --op=show
|
|||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
# type: (*Any, **str) -> None
|
# type: (*Any, **str) -> None
|
||||||
realm = self.get_realm(options)
|
realm = self.get_realm(options)
|
||||||
|
assert realm is not None # Should be ensured by parser
|
||||||
if options["op"] == "show":
|
if options["op"] == "show":
|
||||||
print("%s: %s" % (realm.string_id, all_realm_filters().get(realm.id, [])))
|
print("%s: %s" % (realm.string_id, all_realm_filters().get(realm.id, [])))
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class Command(ZulipBaseCommand):
|
|||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
# type: (**Any) -> None
|
# type: (**Any) -> None
|
||||||
realm = self.get_realm(options)
|
realm = self.get_realm(options)
|
||||||
|
assert realm is not None # Should be ensured by parser
|
||||||
user_profiles = self.get_users(options, realm)
|
user_profiles = self.get_users(options, realm)
|
||||||
stream_name = options["stream"].strip()
|
stream_name = options["stream"].strip()
|
||||||
stream = get_stream(stream_name, realm)
|
stream = get_stream(stream_name, realm)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ class Command(ZulipBaseCommand):
|
|||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
# type: (*Any, **str) -> None
|
# type: (*Any, **str) -> None
|
||||||
realm = self.get_realm(options)
|
realm = self.get_realm(options)
|
||||||
|
assert realm is not None # Should be ensured by parser
|
||||||
old_name = options['old_name']
|
old_name = options['old_name']
|
||||||
new_name = options['new_name']
|
new_name = options['new_name']
|
||||||
encoding = sys.getfilesystemencoding()
|
encoding = sys.getfilesystemencoding()
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ For example:
|
|||||||
with `--streams=`).", file=sys.stderr)
|
with `--streams=`).", file=sys.stderr)
|
||||||
exit(1)
|
exit(1)
|
||||||
realm = self.get_realm(options)
|
realm = self.get_realm(options)
|
||||||
|
assert realm is not None # Should be ensured by parser
|
||||||
|
|
||||||
stream_dict = {
|
stream_dict = {
|
||||||
stream.strip(): {"description": stream.strip(), "invite_only": False}
|
stream.strip(): {"description": stream.strip(), "invite_only": False}
|
||||||
|
|||||||
Reference in New Issue
Block a user