Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCons: Apply new ruff/mypy fixes #102371

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions doc/tools/make_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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(", ")
Expand Down Expand Up @@ -1496,7 +1496,7 @@ def resolve_type(link_type: str) -> 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(", ")
Expand Down Expand Up @@ -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}")
Expand Down
2 changes: 1 addition & 1 deletion gles3_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the offending line, as the original fix was:

-           fd.write("\t\tstatic const char **_variant_defines[]={" "};\n")
+           fd.write("\t\tstatic const char **_variant_defines[]={};\n")

The intent was to have the fallback container store a single value, but the outer double quotes meant Python was concatenating two strings instead, resulting in an empty container. Using single quotes restores the intended behavior.


if header_data.texunits:
fd.write("\t\tstatic TexUnitPair _texunit_pairs[]={\n")
Expand Down
11 changes: 5 additions & 6 deletions methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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

Expand Down Expand Up @@ -1201,7 +1201,7 @@ def get_dependencies(file, env, exts, headers, sources, others):
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 + "'"
Expand All @@ -1217,7 +1217,7 @@ def get_dependencies(file, env, exts, headers, sources, others):
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()
Expand Down Expand Up @@ -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
Expand All @@ -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"):
Expand Down
20 changes: 10 additions & 10 deletions modules/text_server_adv/gdextension_build/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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"])
Expand All @@ -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,
)

Expand Down
14 changes: 7 additions & 7 deletions modules/text_server_fb/gdextension_build/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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])
Expand All @@ -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,
)

Expand Down