mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 12:33:40 +00:00
ruff: Fix UP007 Use X | Y for type annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
e08a24e47f
commit
531b34cb4c
@@ -2,7 +2,6 @@ import logging
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
from typing import Optional
|
||||
|
||||
from scripts.lib.hash_reqs import expand_reqs, python_version
|
||||
from scripts.lib.zulip_tools import ENDC, WARNING, os_families, run, run_as_root
|
||||
@@ -276,7 +275,7 @@ def generate_hash(requirements_file: str) -> str:
|
||||
|
||||
|
||||
def setup_virtualenv(
|
||||
target_venv_path: Optional[str],
|
||||
target_venv_path: str | None,
|
||||
requirements_file: str,
|
||||
patch_activate_script: bool = False,
|
||||
) -> str:
|
||||
|
||||
@@ -5,7 +5,6 @@ import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import Union
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
sys.path.append(BASE_DIR)
|
||||
@@ -46,8 +45,8 @@ def write_updated_configs() -> None:
|
||||
|
||||
nginx_sharding_conf_f.write("map $host $tornado_server {\n")
|
||||
nginx_sharding_conf_f.write(" default http://tornado9800;\n")
|
||||
shard_map: dict[str, Union[int, list[int]]] = {}
|
||||
shard_regexes: list[tuple[str, Union[int, list[int]]]] = []
|
||||
shard_map: dict[str, int | list[int]] = {}
|
||||
shard_regexes: list[tuple[str, int | list[int]]] = []
|
||||
external_host = subprocess.check_output(
|
||||
[os.path.join(BASE_DIR, "scripts/get-django-setting"), "EXTERNAL_HOST"],
|
||||
text=True,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import socket
|
||||
import time
|
||||
from http.client import HTTPConnection
|
||||
from typing import Optional, Union
|
||||
from xmlrpc import client
|
||||
|
||||
from typing_extensions import override
|
||||
@@ -32,9 +31,7 @@ class UnixStreamTransport(client.Transport):
|
||||
super().__init__()
|
||||
|
||||
@override
|
||||
def make_connection(
|
||||
self, host: Union[tuple[str, dict[str, str]], str]
|
||||
) -> UnixStreamHTTPConnection:
|
||||
def make_connection(self, host: tuple[str, dict[str, str]] | str) -> UnixStreamHTTPConnection:
|
||||
return UnixStreamHTTPConnection(self.socket_path)
|
||||
|
||||
|
||||
@@ -45,7 +42,7 @@ def rpc() -> client.ServerProxy:
|
||||
|
||||
|
||||
def list_supervisor_processes(
|
||||
filter_names: Optional[list[str]] = None, *, only_running: Optional[bool] = None
|
||||
filter_names: list[str] | None = None, *, only_running: bool | None = None
|
||||
) -> list[str]:
|
||||
results = []
|
||||
processes = rpc().supervisor.getAllProcessInfo()
|
||||
|
||||
@@ -14,7 +14,7 @@ import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from typing import Literal, Optional
|
||||
from typing import Literal
|
||||
|
||||
os.environ["PYTHONUNBUFFERED"] = "y"
|
||||
|
||||
@@ -122,7 +122,7 @@ old_merge_base = (
|
||||
# Check if rabbitmq port 25672 is listening on anything except 127.0.0.1
|
||||
rabbitmq_dist_listen = listening_publicly(25672)
|
||||
# Check the erlang magic cookie size
|
||||
cookie_size: Optional[int] = None
|
||||
cookie_size: int | None = None
|
||||
if os.path.exists("/var/lib/rabbitmq/.erlang.cookie"):
|
||||
with open("/var/lib/rabbitmq/.erlang.cookie") as cookie_fh:
|
||||
cookie_size = len(cookie_fh.readline())
|
||||
|
||||
@@ -16,7 +16,7 @@ import sys
|
||||
import time
|
||||
import uuid
|
||||
from datetime import datetime, timedelta
|
||||
from typing import IO, Any, Literal, Optional, Sequence, Union, overload
|
||||
from typing import IO, Any, Literal, Sequence, overload
|
||||
from urllib.parse import SplitResult
|
||||
|
||||
import zoneinfo
|
||||
@@ -586,7 +586,7 @@ def get_config(
|
||||
section: str,
|
||||
key: str,
|
||||
default_value: None = None,
|
||||
) -> Optional[str]: ...
|
||||
) -> str | None: ...
|
||||
@overload
|
||||
def get_config(
|
||||
config_file: configparser.RawConfigParser,
|
||||
@@ -602,8 +602,8 @@ def get_config(
|
||||
config_file: configparser.RawConfigParser,
|
||||
section: str,
|
||||
key: str,
|
||||
default_value: Union[str, bool, None] = None,
|
||||
) -> Union[str, bool, None]:
|
||||
default_value: str | bool | None = None,
|
||||
) -> str | bool | None:
|
||||
if config_file.has_option(section, key):
|
||||
val = config_file.get(section, key)
|
||||
if isinstance(default_value, bool):
|
||||
@@ -726,8 +726,8 @@ def listening_publicly(port: int) -> list[str]:
|
||||
def atomic_nagios_write(
|
||||
name: str,
|
||||
status: Literal["ok", "warning", "critical", "unknown"],
|
||||
message: Optional[str] = None,
|
||||
event_time: Optional[int] = None,
|
||||
message: str | None = None,
|
||||
event_time: int | None = None,
|
||||
) -> int:
|
||||
if message is None:
|
||||
message = status
|
||||
|
||||
Reference in New Issue
Block a user