python: Apply changes from pyupgrade.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2022-07-20 22:33:01 -07:00
parent 412e90f601
commit 443b974b3e
2 changed files with 5 additions and 6 deletions

View File

@ -19,8 +19,9 @@ setup_path()
os.environ["DJANGO_SETTINGS_MODULE"] = "zproject.settings"
from typing import Protocol
from django.conf import settings
from typing_extensions import Protocol
from scripts.lib.zulip_tools import BOLD, CYAN, ENDC, FAIL, GRAY, OKBLUE
@ -96,7 +97,7 @@ def parser() -> argparse.ArgumentParser:
def maybe_gzip(logfile_name: str) -> TextIO:
if logfile_name.endswith(".gz"):
return gzip.open(logfile_name, "rt")
return open(logfile_name, "r")
return open(logfile_name)
NGINX_LOG_LINE_RE = re.compile(

View File

@ -220,16 +220,14 @@ class TestMiscStuff(ZulipTestCase):
expected_fields -= {"id"}
stream_dict_fields = set(APIStreamDict.__annotations__.keys())
computed_fields = set(["is_announcement_only", "is_default"])
computed_fields = {"is_announcement_only", "is_default"}
self.assertEqual(stream_dict_fields - computed_fields, expected_fields)
expected_fields = set(Subscription.API_FIELDS)
subscription_dict_fields = set(APISubscriptionDict.__annotations__.keys())
computed_fields = set(
["in_home_view", "email_address", "stream_weekly_traffic", "subscribers"]
)
computed_fields = {"in_home_view", "email_address", "stream_weekly_traffic", "subscribers"}
# `APISubscriptionDict` is a subclass of `APIStreamDict`, therefore having all the
# fields in addition to the computed fields and `Subscription.API_FIELDS` that
# need to be excluded here.