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,12 +1,12 @@
import subprocess
from typing import List, Optional
from typing import Optional
from zulint.printer import BOLDRED, CYAN, ENDC, GREEN
from .template_parser import Token
def shift_indents_to_the_next_tokens(tokens: List[Token]) -> None:
def shift_indents_to_the_next_tokens(tokens: list[Token]) -> None:
"""
During the parsing/validation phase, it's useful to have separate
tokens for "indent" chunks, but during pretty printing, we like
@@ -39,7 +39,7 @@ def token_allows_children_to_skip_indents(token: Token) -> bool:
return token.kind in ("django_start", "handlebars_start") or token.tag == "a"
def adjust_block_indentation(tokens: List[Token], fn: str) -> None:
def adjust_block_indentation(tokens: list[Token], fn: str) -> None:
start_token: Optional[Token] = None
for token in tokens:
@@ -106,7 +106,7 @@ def adjust_block_indentation(tokens: List[Token], fn: str) -> None:
token.indent = start_token.child_indent
def fix_indents_for_multi_line_tags(tokens: List[Token]) -> None:
def fix_indents_for_multi_line_tags(tokens: list[Token]) -> None:
def fix(frag: str) -> str:
frag = frag.strip()
return continue_indent + frag if frag else ""
@@ -128,13 +128,13 @@ def fix_indents_for_multi_line_tags(tokens: List[Token]) -> None:
token.new_s = frags[0] + "\n" + "\n".join(fix(frag) for frag in frags[1:])
def apply_token_indents(tokens: List[Token]) -> None:
def apply_token_indents(tokens: list[Token]) -> None:
for token in tokens:
if token.indent:
token.new_s = token.indent + token.new_s
def pretty_print_html(tokens: List[Token], fn: str) -> str:
def pretty_print_html(tokens: list[Token], fn: str) -> str:
for token in tokens:
token.new_s = token.s
@@ -150,7 +150,7 @@ def numbered_lines(s: str) -> str:
return "".join(f"{i + 1: >5} {line}\n" for i, line in enumerate(s.split("\n")))
def validate_indent_html(fn: str, tokens: List[Token], fix: bool) -> bool:
def validate_indent_html(fn: str, tokens: list[Token], fix: bool) -> bool:
with open(fn) as f:
html = f.read()
phtml = pretty_print_html(tokens, fn)