Sfoglia il codice sorgente

SCons: Apply new ruff/mypy fixes

Thaddeus Crews 5 mesi fa
parent
commit
382c760ea6

+ 2 - 3
SConstruct

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

+ 4 - 4
doc/tools/make_rst.py

@@ -920,7 +920,7 @@ def make_rst_class(class_def: ClassDef, state: State, dry_run: bool, output_dir:
         # Ascendants
         if class_def.inherits:
             inherits = class_def.inherits.strip()
-            f.write(f'**{translate("Inherits:")}** ')
+            f.write(f"**{translate('Inherits:')}** ")
             first = True
             while inherits is not None:
                 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)
 
         if len(inherited):
-            f.write(f'**{translate("Inherited By:")}** ')
+            f.write(f"**{translate('Inherited By:')}** ")
             for i, child in enumerate(inherited):
                 if i > 0:
                     f.write(", ")
@@ -1496,7 +1496,7 @@ def make_type(klass: str, state: State) -> str:
             return f"``{link_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.
         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):
             if column_sizes[i] == 0 and remove_empty_columns:
                 continue
-            row_text += f' {(text or "").ljust(column_sizes[i])} |'
+            row_text += f" {(text or '').ljust(column_sizes[i])} |"
         row_text += "\n"
 
         f.write(f"   {row_text}")

+ 1 - 1
gles3_builders.py

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

+ 5 - 6
methods.py

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

+ 10 - 10
modules/text_server_adv/gdextension_build/SConstruct

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

+ 7 - 7
modules/text_server_fb/gdextension_build/SConstruct

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