SCons: Apply new ruff/mypy fixes

This commit is contained in:
Thaddeus Crews 2025-02-03 09:55:09 -06:00
parent f60f69aa57
commit 382c760ea6
No known key found for this signature in database
GPG Key ID: 62181B86FE9E5D84
6 changed files with 29 additions and 31 deletions

View File

@ -313,7 +313,7 @@ if not env["platform"]:
env["platform"] = "windows" env["platform"] = "windows"
if env["platform"]: if env["platform"]:
print(f'Automatically detected platform: {env["platform"]}') print(f"Automatically detected platform: {env['platform']}")
# Deprecated aliases kept for compatibility. # Deprecated aliases kept for compatibility.
if env["platform"] in compatibility_platform_aliases: if env["platform"] in compatibility_platform_aliases:
@ -998,8 +998,7 @@ if env["disable_3d"]:
if env["disable_advanced_gui"]: if env["disable_advanced_gui"]:
if env.editor_build: if env.editor_build:
print_error( print_error(
"Build option `disable_advanced_gui=yes` cannot be used for editor builds, " "Build option `disable_advanced_gui=yes` cannot be used for editor builds, only for export template builds."
"only for export template builds."
) )
Exit(255) Exit(255)
else: else:

View File

@ -920,7 +920,7 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
# Ascendants # Ascendants
if class_def.inherits: if class_def.inherits:
inherits = class_def.inherits.strip() inherits = class_def.inherits.strip()
f.write(f'**{translate("Inherits:")}** ') f.write(f"**{translate('Inherits:')}** ")
first = True first = True
while inherits is not None: while inherits is not None:
if not first: if not first:
@ -947,7 +947,7 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
inherited.append(c.name) inherited.append(c.name)
if len(inherited): if len(inherited):
f.write(f'**{translate("Inherited By:")}** ') f.write(f"**{translate('Inherited By:')}** ")
for i, child in enumerate(inherited): for i, child in enumerate(inherited):
if i > 0: if i > 0:
f.write(", ") f.write(", ")
@ -1496,7 +1496,7 @@ def make_type(klass: str, state: State) -> str:
return f"``{link_type}``" return f"``{link_type}``"
if klass.endswith("[]"): # Typed array, strip [] to link to contained type. if klass.endswith("[]"): # Typed array, strip [] to link to contained type.
return f":ref:`Array<class_Array>`\\[{resolve_type(klass[:-len('[]')])}\\]" return f":ref:`Array<class_Array>`\\[{resolve_type(klass[: -len('[]')])}\\]"
if klass.startswith("Dictionary["): # Typed dictionary, split elements to link contained types. if klass.startswith("Dictionary["): # Typed dictionary, split elements to link contained types.
parts = klass[len("Dictionary[") : -len("]")].partition(", ") parts = klass[len("Dictionary[") : -len("]")].partition(", ")
@ -2542,7 +2542,7 @@ def format_table(f: TextIO, data: List[Tuple[Optional[str], ...]], remove_empty_
for i, text in enumerate(row): for i, text in enumerate(row):
if column_sizes[i] == 0 and remove_empty_columns: if column_sizes[i] == 0 and remove_empty_columns:
continue continue
row_text += f' {(text or "").ljust(column_sizes[i])} |' row_text += f" {(text or '').ljust(column_sizes[i])} |"
row_text += "\n" row_text += "\n"
f.write(f" {row_text}") f.write(f" {row_text}")

View File

@ -499,7 +499,7 @@ def build_gles3_header(
fd.write("\t\t};\n\n") fd.write("\t\t};\n\n")
variant_count = len(header_data.variant_defines) variant_count = len(header_data.variant_defines)
else: else:
fd.write("\t\tstatic const char **_variant_defines[]={" "};\n") fd.write('\t\tstatic const char **_variant_defines[]={" "};\n')
if header_data.texunits: if header_data.texunits:
fd.write("\t\tstatic TexUnitPair _texunit_pairs[]={\n") fd.write("\t\tstatic TexUnitPair _texunit_pairs[]={\n")

View File

@ -7,7 +7,7 @@ import re
import subprocess import subprocess
import sys import sys
from collections import OrderedDict from collections import OrderedDict
from io import StringIO, TextIOWrapper from io import StringIO, TextIOBase
from pathlib import Path from pathlib import Path
from typing import Generator, List, Optional, Union, cast from typing import Generator, List, Optional, Union, cast
@ -1201,7 +1201,7 @@ def generate_vs_project(env, original_args, project_name="godot"):
vsconf = "" vsconf = ""
for a in vs_configuration["arches"]: for a in vs_configuration["arches"]:
if arch == a["architecture"]: if arch == a["architecture"]:
vsconf = f'{target}|{a["platform"]}' vsconf = f"{target}|{a['platform']}"
break break
condition = "'$(GodotConfiguration)|$(GodotPlatform)'=='" + vsconf + "'" condition = "'$(GodotConfiguration)|$(GodotPlatform)'=='" + vsconf + "'"
@ -1217,7 +1217,7 @@ def generate_vs_project(env, original_args, project_name="godot"):
properties.append( properties.append(
"<ActiveProjectItemList_%s>;%s;</ActiveProjectItemList_%s>" % (x, ";".join(itemlist[x]), x) "<ActiveProjectItemList_%s>;%s;</ActiveProjectItemList_%s>" % (x, ";".join(itemlist[x]), x)
) )
output = f'bin\\godot{env["PROGSUFFIX"]}' output = f"bin\\godot{env['PROGSUFFIX']}"
with open("misc/msvs/props.template", "r", encoding="utf-8") as file: with open("misc/msvs/props.template", "r", encoding="utf-8") as file:
props_template = file.read() props_template = file.read()
@ -1453,7 +1453,7 @@ def generated_wrapper(
guard: Optional[bool] = None, guard: Optional[bool] = None,
prefix: str = "", prefix: str = "",
suffix: str = "", suffix: str = "",
) -> Generator[TextIOWrapper, None, None]: ) -> Generator[TextIOBase, None, None]:
""" """
Wrapper class to automatically handle copyright headers and header guards Wrapper class to automatically handle copyright headers and header guards
for generated scripts. Meant to be invoked via `with` statement similar to for generated scripts. Meant to be invoked via `with` statement similar to
@ -1475,8 +1475,7 @@ def generated_wrapper(
if isinstance(path, list): if isinstance(path, list):
if len(path) > 1: if len(path) > 1:
print_warning( print_warning(
"Attempting to use generated wrapper with multiple targets; " f"Attempting to use generated wrapper with multiple targets; will only use first entry: {path[0]}"
f"will only use first entry: {path[0]}"
) )
path = path[0] path = path[0]
if not hasattr(path, "get_abspath"): if not hasattr(path, "get_abspath"):

View File

@ -110,7 +110,7 @@ if env["thorvg_enabled"] and env["freetype_enabled"]:
env.Append(CPPDEFINES=["MODULE_SVG_ENABLED"]) env.Append(CPPDEFINES=["MODULE_SVG_ENABLED"])
lib = env_tvg.Library( lib = env_tvg.Library(
f'tvg_builtin{env["suffix"]}{env["LIBSUFFIX"]}', f"tvg_builtin{env['suffix']}{env['LIBSUFFIX']}",
thirdparty_tvg_sources, thirdparty_tvg_sources,
) )
env.Append(LIBS=[lib]) env.Append(LIBS=[lib])
@ -155,7 +155,7 @@ if env["msdfgen_enabled"] and env["freetype_enabled"]:
env.Append(CPPDEFINES=["MODULE_MSDFGEN_ENABLED"]) env.Append(CPPDEFINES=["MODULE_MSDFGEN_ENABLED"])
lib = env_msdfgen.Library( lib = env_msdfgen.Library(
f'msdfgen_builtin{env["suffix"]}{env["LIBSUFFIX"]}', f"msdfgen_builtin{env['suffix']}{env['LIBSUFFIX']}",
thirdparty_msdfgen_sources, thirdparty_msdfgen_sources,
) )
env.Append(LIBS=[lib]) env.Append(LIBS=[lib])
@ -284,7 +284,7 @@ if env["freetype_enabled"]:
env.Append(CPPDEFINES=["MODULE_FREETYPE_ENABLED"]) env.Append(CPPDEFINES=["MODULE_FREETYPE_ENABLED"])
lib = env_freetype.Library( lib = env_freetype.Library(
f'freetype_builtin{env["suffix"]}{env["LIBSUFFIX"]}', f"freetype_builtin{env['suffix']}{env['LIBSUFFIX']}",
thirdparty_freetype_sources, thirdparty_freetype_sources,
) )
env.Append(LIBS=[lib]) env.Append(LIBS=[lib])
@ -418,7 +418,7 @@ if env["freetype_enabled"]:
env.Append(CPPPATH=["../../../thirdparty/harfbuzz/src"]) env.Append(CPPPATH=["../../../thirdparty/harfbuzz/src"])
lib = env_harfbuzz.Library( lib = env_harfbuzz.Library(
f'harfbuzz_builtin{env["suffix"]}{env["LIBSUFFIX"]}', f"harfbuzz_builtin{env['suffix']}{env['LIBSUFFIX']}",
thirdparty_harfbuzz_sources, thirdparty_harfbuzz_sources,
) )
env.Prepend(LIBS=[lib]) env.Prepend(LIBS=[lib])
@ -478,7 +478,7 @@ if env["graphite_enabled"] and env["freetype_enabled"]:
) )
lib = env_graphite.Library( lib = env_graphite.Library(
f'graphite_builtin{env["suffix"]}{env["LIBSUFFIX"]}', f"graphite_builtin{env['suffix']}{env['LIBSUFFIX']}",
thirdparty_graphite_sources, thirdparty_graphite_sources,
) )
env.Append(LIBS=[lib]) env.Append(LIBS=[lib])
@ -737,7 +737,7 @@ env.Append(CPPPATH=["../../../thirdparty/icu4c/common/", "../../../thirdparty/ic
if env["platform"] == "windows": if env["platform"] == "windows":
env.Append(LIBS=["advapi32"]) env.Append(LIBS=["advapi32"])
lib = env_icu.Library(f'icu_builtin{env["suffix"]}{env["LIBSUFFIX"]}', thirdparty_icu_sources) lib = env_icu.Library(f"icu_builtin{env['suffix']}{env['LIBSUFFIX']}", thirdparty_icu_sources)
env.Append(LIBS=[lib]) env.Append(LIBS=[lib])
env.Append(CPPDEFINES=["GDEXTENSION"]) env.Append(CPPDEFINES=["GDEXTENSION"])
@ -746,18 +746,18 @@ sources = Glob("../*.cpp")
if env["platform"] == "macos": if env["platform"] == "macos":
methods.write_macos_plist( methods.write_macos_plist(
f'./bin/libtextserver_advanced.macos.{env["target"]}.framework', f"./bin/libtextserver_advanced.macos.{env['target']}.framework",
f'libtextserver_advanced.macos.{env["target"]}', f"libtextserver_advanced.macos.{env['target']}",
"org.godotengine.textserver_advanced", "org.godotengine.textserver_advanced",
"ICU / HarfBuzz / Graphite Text Server", "ICU / HarfBuzz / Graphite Text Server",
) )
library = env.SharedLibrary( library = env.SharedLibrary(
f'./bin/libtextserver_advanced.macos.{env["target"]}.framework/libtextserver_advanced.macos.{env["target"]}', f"./bin/libtextserver_advanced.macos.{env['target']}.framework/libtextserver_advanced.macos.{env['target']}",
source=sources, source=sources,
) )
else: else:
library = env.SharedLibrary( library = env.SharedLibrary(
f'./bin/libtextserver_advanced{env["suffix"]}{env["SHLIBSUFFIX"]}', f"./bin/libtextserver_advanced{env['suffix']}{env['SHLIBSUFFIX']}",
source=sources, source=sources,
) )

View File

@ -105,7 +105,7 @@ if env["thorvg_enabled"] and env["freetype_enabled"]:
env.Append(CPPDEFINES=["MODULE_SVG_ENABLED"]) env.Append(CPPDEFINES=["MODULE_SVG_ENABLED"])
lib = env_tvg.Library( lib = env_tvg.Library(
f'tvg_builtin{env["suffix"]}{env["LIBSUFFIX"]}', f"tvg_builtin{env['suffix']}{env['LIBSUFFIX']}",
thirdparty_tvg_sources, thirdparty_tvg_sources,
) )
env.Append(LIBS=[lib]) env.Append(LIBS=[lib])
@ -150,7 +150,7 @@ if env["msdfgen_enabled"] and env["freetype_enabled"]:
env.Append(CPPDEFINES=["MODULE_MSDFGEN_ENABLED"]) env.Append(CPPDEFINES=["MODULE_MSDFGEN_ENABLED"])
lib = env_msdfgen.Library( lib = env_msdfgen.Library(
f'msdfgen_builtin{env["suffix"]}{env["LIBSUFFIX"]}', f"msdfgen_builtin{env['suffix']}{env['LIBSUFFIX']}",
thirdparty_msdfgen_sources, thirdparty_msdfgen_sources,
) )
env.Append(LIBS=[lib]) env.Append(LIBS=[lib])
@ -279,7 +279,7 @@ if env["freetype_enabled"]:
env.Append(CPPDEFINES=["MODULE_FREETYPE_ENABLED"]) env.Append(CPPDEFINES=["MODULE_FREETYPE_ENABLED"])
lib = env_freetype.Library( lib = env_freetype.Library(
f'freetype_builtin{env["suffix"]}{env["LIBSUFFIX"]}', f"freetype_builtin{env['suffix']}{env['LIBSUFFIX']}",
thirdparty_freetype_sources, thirdparty_freetype_sources,
) )
env.Append(LIBS=[lib]) env.Append(LIBS=[lib])
@ -291,18 +291,18 @@ sources = Glob("../*.cpp")
if env["platform"] == "macos": if env["platform"] == "macos":
methods.write_macos_plist( methods.write_macos_plist(
f'./bin/libtextserver_fallback.macos.{env["target"]}.framework', f"./bin/libtextserver_fallback.macos.{env['target']}.framework",
f'libtextserver_fallback.macos.{env["target"]}', f"libtextserver_fallback.macos.{env['target']}",
"org.godotengine.textserver_fallback", "org.godotengine.textserver_fallback",
"Fallback Text Server", "Fallback Text Server",
) )
library = env.SharedLibrary( library = env.SharedLibrary(
f'./bin/libtextserver_fallback.macos.{env["target"]}.framework/libtextserver_fallback.macos.{env["target"]}', f"./bin/libtextserver_fallback.macos.{env['target']}.framework/libtextserver_fallback.macos.{env['target']}",
source=sources, source=sources,
) )
else: else:
library = env.SharedLibrary( library = env.SharedLibrary(
f'./bin/libtextserver_fallback{env["suffix"]}{env["SHLIBSUFFIX"]}', f"./bin/libtextserver_fallback{env['suffix']}{env['SHLIBSUFFIX']}",
source=sources, source=sources,
) )