You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-12-02 16:48:55 +00:00
SCons: Integrate annotations where relevant
• Expand Ruff linter to catch & upgrade legacy type-hint syntax
This commit is contained in:
@@ -4,10 +4,11 @@
|
||||
# the Unicode Character Database to the `char_range.inc` file.
|
||||
# NOTE: This script is deliberately not integrated into the build system;
|
||||
# you should run it manually whenever you want to update the data.
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
from typing import Final, List, Tuple
|
||||
from typing import Final
|
||||
from urllib.request import urlopen
|
||||
|
||||
if __name__ == "__main__":
|
||||
@@ -18,20 +19,20 @@ from methods import generate_copyright_header
|
||||
URL: Final[str] = "https://www.unicode.org/Public/16.0.0/ucd/DerivedCoreProperties.txt"
|
||||
|
||||
|
||||
xid_start: List[Tuple[int, int]] = []
|
||||
xid_continue: List[Tuple[int, int]] = []
|
||||
uppercase_letter: List[Tuple[int, int]] = []
|
||||
lowercase_letter: List[Tuple[int, int]] = []
|
||||
unicode_letter: List[Tuple[int, int]] = []
|
||||
xid_start: list[tuple[int, int]] = []
|
||||
xid_continue: list[tuple[int, int]] = []
|
||||
uppercase_letter: list[tuple[int, int]] = []
|
||||
lowercase_letter: list[tuple[int, int]] = []
|
||||
unicode_letter: list[tuple[int, int]] = []
|
||||
|
||||
|
||||
def merge_ranges(ranges: List[Tuple[int, int]]) -> None:
|
||||
def merge_ranges(ranges: list[tuple[int, int]]) -> None:
|
||||
if len(ranges) < 2:
|
||||
return
|
||||
|
||||
last_start: int = ranges[0][0]
|
||||
last_end: int = ranges[0][1]
|
||||
original_ranges: List[Tuple[int, int]] = ranges[1:]
|
||||
original_ranges: list[tuple[int, int]] = ranges[1:]
|
||||
|
||||
ranges.clear()
|
||||
|
||||
@@ -47,13 +48,13 @@ def merge_ranges(ranges: List[Tuple[int, int]]) -> None:
|
||||
|
||||
|
||||
def parse_unicode_data() -> None:
|
||||
lines: List[str] = [line.decode("utf-8") for line in urlopen(URL)]
|
||||
lines: list[str] = [line.decode("utf-8") for line in urlopen(URL)]
|
||||
|
||||
for line in lines:
|
||||
if line.startswith("#") or not line.strip():
|
||||
continue
|
||||
|
||||
split_line: List[str] = line.split(";")
|
||||
split_line: list[str] = line.split(";")
|
||||
|
||||
char_range: str = split_line[0].strip()
|
||||
char_property: str = split_line[1].strip().split("#")[0].strip()
|
||||
@@ -63,7 +64,7 @@ def parse_unicode_data() -> None:
|
||||
if ".." in char_range:
|
||||
range_start, range_end = char_range.split("..")
|
||||
|
||||
range_tuple: Tuple[int, int] = (int(range_start, 16), int(range_end, 16))
|
||||
range_tuple: tuple[int, int] = (int(range_start, 16), int(range_end, 16))
|
||||
|
||||
if char_property == "XID_Start":
|
||||
xid_start.append(range_tuple)
|
||||
@@ -87,7 +88,7 @@ def parse_unicode_data() -> None:
|
||||
merge_ranges(unicode_letter)
|
||||
|
||||
|
||||
def make_array(array_name: str, range_list: List[Tuple[int, int]]) -> str:
|
||||
def make_array(array_name: str, range_list: list[tuple[int, int]]) -> str:
|
||||
result: str = f"\n\nconstexpr inline CharRange {array_name}[] = {{\n"
|
||||
|
||||
for start, end in range_list:
|
||||
|
||||
Reference in New Issue
Block a user