ruff: Fix UP006 Use list instead of List for type annotation.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2024-07-11 17:30:17 -07:00
committed by Tim Abbott
parent c2214b3904
commit e08a24e47f
457 changed files with 3588 additions and 3857 deletions

View File

@@ -1,7 +1,7 @@
import itertools
import os
import random
from typing import Any, Dict, List
from typing import Any
import orjson
@@ -9,14 +9,14 @@ from scripts.lib.zulip_tools import get_or_create_dev_uuid_var_path
from zerver.lib.topic import RESOLVED_TOPIC_PREFIX
def load_config() -> Dict[str, Any]:
def load_config() -> dict[str, Any]:
with open("zerver/tests/fixtures/config.generate_data.json", "rb") as infile:
config = orjson.loads(infile.read())
return config
def generate_topics(num_topics: int) -> List[str]:
def generate_topics(num_topics: int) -> list[str]:
config = load_config()["gen_fodder"]
# Make single word topics account for 30% of total topics.
@@ -54,7 +54,7 @@ def generate_topics(num_topics: int) -> List[str]:
]
def load_generators(config: Dict[str, Any]) -> Dict[str, Any]:
def load_generators(config: dict[str, Any]) -> dict[str, Any]:
results = {}
cfg = config["gen_fodder"]
@@ -77,11 +77,11 @@ def load_generators(config: Dict[str, Any]) -> Dict[str, Any]:
return results
def parse_file(config: Dict[str, Any], gens: Dict[str, Any], corpus_file: str) -> List[str]:
def parse_file(config: dict[str, Any], gens: dict[str, Any], corpus_file: str) -> list[str]:
# First, load the entire file into a dictionary,
# then apply our custom filters to it as needed.
paragraphs: List[str] = []
paragraphs: list[str] = []
with open(corpus_file) as infile:
# OUR DATA: we need to separate the person talking and what they say
@@ -91,7 +91,7 @@ def parse_file(config: Dict[str, Any], gens: Dict[str, Any], corpus_file: str) -
return paragraphs
def get_flair_gen(length: int) -> List[str]:
def get_flair_gen(length: int) -> list[str]:
# Grab the percentages from the config file
# create a list that we can consume that will guarantee the distribution
result = []
@@ -105,7 +105,7 @@ def get_flair_gen(length: int) -> List[str]:
return result
def add_flair(paragraphs: List[str], gens: Dict[str, Any]) -> List[str]:
def add_flair(paragraphs: list[str], gens: dict[str, Any]) -> list[str]:
# roll the dice and see what kind of flair we should add, if any
results = []
@@ -183,7 +183,7 @@ def add_link(text: str, link: str) -> str:
return " ".join(vals)
def remove_line_breaks(fh: Any) -> List[str]:
def remove_line_breaks(fh: Any) -> list[str]:
# We're going to remove line breaks from paragraphs
results = [] # save the dialogs as tuples with (author, dialog)
@@ -204,7 +204,7 @@ def remove_line_breaks(fh: Any) -> List[str]:
return results
def write_file(paragraphs: List[str], filename: str) -> None:
def write_file(paragraphs: list[str], filename: str) -> None:
with open(filename, "wb") as outfile:
outfile.write(orjson.dumps(paragraphs))