Skip to content

Commit

Permalink
python: Apply changes from pyupgrade.
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk committed Jul 21, 2022
1 parent 412e90f commit 443b974
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 3 additions & 2 deletions scripts/log-search
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand Down
6 changes: 2 additions & 4 deletions zerver/tests/test_subs.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,14 @@ def test_api_fields(self) -> None:
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.
Expand Down

0 comments on commit 443b974

Please sign in to comment.