From f7e97b11808153724cf34b660ccceda057478ac5 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sun, 11 Dec 2022 01:46:24 -0800 Subject: [PATCH] ruff: Fix PLW0602 Using global but no assignment is done. Signed-off-by: Anders Kaseorg --- .../nagios_plugins/zulip_app_frontend/check_send_receive_time | 2 +- zerver/lib/cache.py | 1 - zerver/lib/markdown/__init__.py | 3 --- zerver/lib/rate_limiter.py | 3 --- zerver/views/zephyr.py | 1 - 5 files changed, 1 insertion(+), 9 deletions(-) diff --git a/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time b/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time index ad202cf4fe..5c82559f0c 100755 --- a/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time +++ b/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time @@ -96,7 +96,7 @@ def send_zulip(sender: zulip.Client, message: Dict[str, Any]) -> None: def get_zulips() -> List[Dict[str, Any]]: - global queue_id, last_event_id + global last_event_id res = zulip_recipient.get_events(queue_id=queue_id, last_event_id=last_event_id) if "error" in res.get("result", {}): report("CRITICAL", msg="Error receiving Zulips, error was: {}".format(res["msg"])) diff --git a/zerver/lib/cache.py b/zerver/lib/cache.py index 56dd6673f3..13c9933d88 100644 --- a/zerver/lib/cache.py +++ b/zerver/lib/cache.py @@ -65,7 +65,6 @@ def remote_cache_stats_start() -> None: def remote_cache_stats_finish() -> None: global remote_cache_total_time global remote_cache_total_requests - global remote_cache_time_start remote_cache_total_requests += 1 remote_cache_total_time += time.time() - remote_cache_time_start diff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.py index a6c47706b6..277994bf3f 100644 --- a/zerver/lib/markdown/__init__.py +++ b/zerver/lib/markdown/__init__.py @@ -2491,8 +2491,6 @@ def topic_links(linkifiers_key: int, topic_name: str) -> List[Dict[str, str]]: def maybe_update_markdown_engines(linkifiers_key: int, email_gateway: bool) -> None: - global linkifier_data - linkifiers = linkifiers_for_realm(linkifiers_key) if linkifiers_key not in linkifier_data or linkifier_data[linkifiers_key] != linkifiers: # Linkifier data has changed, update `linkifier_data` and any @@ -2676,7 +2674,6 @@ def markdown_stats_start() -> None: def markdown_stats_finish() -> None: global markdown_total_time global markdown_total_requests - global markdown_time_start markdown_total_requests += 1 markdown_total_time += time.time() - markdown_time_start diff --git a/zerver/lib/rate_limiter.py b/zerver/lib/rate_limiter.py index 3b824563cb..5f198a4149 100644 --- a/zerver/lib/rate_limiter.py +++ b/zerver/lib/rate_limiter.py @@ -162,8 +162,6 @@ def bounce_redis_key_prefix_for_testing(test_name: str) -> None: def add_ratelimit_rule(range_seconds: int, num_requests: int, domain: str = "api_by_user") -> None: "Add a rate-limiting rule to the ratelimiter" - global rules - if domain not in rules: # If we don't have any rules for domain yet, the domain key needs to be # added to the rules dictionary. @@ -176,7 +174,6 @@ def add_ratelimit_rule(range_seconds: int, num_requests: int, domain: str = "api def remove_ratelimit_rule( range_seconds: int, num_requests: int, domain: str = "api_by_user" ) -> None: - global rules rules[domain] = [x for x in rules[domain] if x[0] != range_seconds and x[1] != num_requests] diff --git a/zerver/views/zephyr.py b/zerver/views/zephyr.py index a71178f504..cd2d348376 100644 --- a/zerver/views/zephyr.py +++ b/zerver/views/zephyr.py @@ -32,7 +32,6 @@ kerberos_alter_egos = { def webathena_kerberos_login( request: HttpRequest, user_profile: UserProfile, cred: Optional[str] = REQ(default=None) ) -> HttpResponse: - global kerberos_alter_egos if cred is None: raise JsonableError(_("Could not find Kerberos credential")) if not user_profile.realm.webathena_enabled: