From c9c941e339a6632247b6bd073d10bea548bed20b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 19 Jun 2023 23:33:02 +0200 Subject: [PATCH] CI: Update static checks to black 23.3.0 And apply it to the codebase, removing empty lines at the start of blocks. --- .github/workflows/static_checks.yml | 2 +- core/core_builders.py | 1 - core/object/make_virtuals.py | 2 -- doc/tools/make_rst.py | 1 - editor/editor_builders.py | 3 --- editor/icons/editor_icons_builders.py | 4 +--- gles3_builders.py | 7 ------- glsl_builders.py | 2 -- methods.py | 9 --------- modules/denoise/resource_to_cpp.py | 2 +- platform/uwp/detect.py | 1 - platform_methods.py | 1 - .../default_theme/default_theme_icons_builders.py | 3 --- scu_builders.py | 4 +--- 14 files changed, 4 insertions(+), 38 deletions(-) diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml index c6ec244b7d88..6133780688a9 100644 --- a/.github/workflows/static_checks.yml +++ b/.github/workflows/static_checks.yml @@ -23,7 +23,7 @@ jobs: - name: Install Python dependencies and general setup run: | - pip3 install black==22.3.0 pytest==7.1.2 mypy==0.971 + pip3 install black==23.3.0 pytest==7.1.2 mypy==0.971 git config diff.wsErrorHighlight all - name: Get changed files diff --git a/core/core_builders.py b/core/core_builders.py index b0a3b85d58c2..e40ebbb14d42 100644 --- a/core/core_builders.py +++ b/core/core_builders.py @@ -239,7 +239,6 @@ def next_tag(self): data_list += part["Copyright"] with open(dst, "w", encoding="utf-8") as f: - f.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") f.write("#ifndef LICENSE_GEN_H\n") f.write("#define LICENSE_GEN_H\n") diff --git a/core/object/make_virtuals.py b/core/object/make_virtuals.py index 18f27ae4a4ad..5be9650b3240 100644 --- a/core/object/make_virtuals.py +++ b/core/object/make_virtuals.py @@ -154,7 +154,6 @@ def generate_version(argcount, const=False, returns=False): def run(target, source, env): - max_versions = 12 txt = """ @@ -165,7 +164,6 @@ def run(target, source, env): """ for i in range(max_versions + 1): - txt += "/* " + str(i) + " Arguments */\n\n" txt += generate_version(i, False, False) txt += generate_version(i, False, True) diff --git a/doc/tools/make_rst.py b/doc/tools/make_rst.py index 7cc05087b7f0..0649a0bb621f 100755 --- a/doc/tools/make_rst.py +++ b/doc/tools/make_rst.py @@ -1466,7 +1466,6 @@ def make_link(url: str, title: str) -> str: def make_rst_index(grouped_classes: Dict[str, List[str]], dry_run: bool, output_dir: str) -> None: - if dry_run: f = open(os.devnull, "w", encoding="utf-8") else: diff --git a/editor/editor_builders.py b/editor/editor_builders.py index ce6abeb07ae7..90ecccbf3050 100644 --- a/editor/editor_builders.py +++ b/editor/editor_builders.py @@ -14,7 +14,6 @@ def make_doc_header(target, source, env): - dst = target[0] g = open(dst, "w", encoding="utf-8") buf = "" @@ -51,7 +50,6 @@ def make_doc_header(target, source, env): def make_fonts_header(target, source, env): - dst = target[0] g = open(dst, "w", encoding="utf-8") @@ -80,7 +78,6 @@ def make_fonts_header(target, source, env): def make_translations_header(target, source, env, category): - dst = target[0] g = open(dst, "w", encoding="utf-8") diff --git a/editor/icons/editor_icons_builders.py b/editor/icons/editor_icons_builders.py index 2b621071ce7e..ae25072a9eaa 100644 --- a/editor/icons/editor_icons_builders.py +++ b/editor/icons/editor_icons_builders.py @@ -8,16 +8,15 @@ from io import StringIO from platform_methods import subprocess_main + # See also `scene/resources/default_theme/default_theme_icons_builders.py`. def make_editor_icons_action(target, source, env): - dst = target[0] svg_icons = source icons_string = StringIO() for f in svg_icons: - fname = str(f) icons_string.write('\t"') @@ -48,7 +47,6 @@ def make_editor_icons_action(target, source, env): thumb_big_indices = [] index = 0 for f in svg_icons: - fname = str(f) # Trim the `.svg` extension from the string. diff --git a/gles3_builders.py b/gles3_builders.py index 6b5a53221c85..0b6a3c25424f 100644 --- a/gles3_builders.py +++ b/gles3_builders.py @@ -40,7 +40,6 @@ def include_file_in_gles3_header(filename: str, header_data: GLES3HeaderStruct, line = fs.readline() while line: - if line.find("=") != -1 and header_data.reading == "": # Mode eqpos = line.find("=") @@ -121,7 +120,6 @@ def include_file_in_gles3_header(filename: str, header_data: GLES3HeaderStruct, uline = uline.replace(";", "") lines = uline.split(",") for x in lines: - x = x.strip() x = x[x.rfind(" ") + 1 :] if x.find("[") != -1: @@ -143,7 +141,6 @@ def include_file_in_gles3_header(filename: str, header_data: GLES3HeaderStruct, uline = uline.replace("{", "").strip() lines = uline.split(",") for x in lines: - x = x.strip() x = x[x.rfind(" ") + 1 :] if x.find("[") != -1: @@ -159,7 +156,6 @@ def include_file_in_gles3_header(filename: str, header_data: GLES3HeaderStruct, uline = uline.replace(";", "") lines = uline.split(",") for x in lines: - x = x.strip() x = x[x.rfind(" ") + 1 :] if x.find("[") != -1: @@ -486,7 +482,6 @@ def build_gles3_header( fd.write("\tvirtual void _init() override {\n\n") if header_data.uniforms: - fd.write("\t\tstatic const char* _uniform_strings[]={\n") if header_data.uniforms: for x in header_data.uniforms: @@ -497,7 +492,6 @@ def build_gles3_header( variant_count = 1 if len(header_data.variant_defines) > 0: - fd.write("\t\tstatic const char* _variant_defines[]={\n") for x in header_data.variant_defines: fd.write('\t\t\t"' + x + '",\n') @@ -542,7 +536,6 @@ def build_gles3_header( feedback_count = 0 if header_data.feedbacks: - fd.write("\t\tstatic const Feedback _feedbacks[]={\n") for x in header_data.feedbacks: name = x[0] diff --git a/glsl_builders.py b/glsl_builders.py index 1dcae2fd7577..706b50636e55 100644 --- a/glsl_builders.py +++ b/glsl_builders.py @@ -47,7 +47,6 @@ def include_file_in_rd_header(filename: str, header_data: RDHeaderStruct, depth: line = fs.readline() while line: - index = line.find("//") if index != -1: line = line[:index] @@ -184,7 +183,6 @@ def include_file_in_raw_header(filename: str, header_data: RAWHeaderStruct, dept line = fs.readline() while line: - while line.find("#include ") != -1: includeline = line.replace("#include ", "").strip()[1:-1] diff --git a/methods.py b/methods.py index 18b4ceb74fa6..4c1357c688a7 100644 --- a/methods.py +++ b/methods.py @@ -259,14 +259,11 @@ def generate_version_header(module_version_string=""): def parse_cg_file(fname, uniforms, sizes, conditionals): - fs = open(fname, "r") line = fs.readline() while line: - if re.match(r"^\s*uniform", line): - res = re.match(r"uniform ([\d\w]*) ([\d\w]*)") type = res.groups(1) name = res.groups(2) @@ -507,7 +504,6 @@ def sort_module_list(env): def use_windows_spawn_fix(self, platform=None): - if os.name != "nt": return # not needed, only for windows @@ -522,7 +518,6 @@ def use_windows_spawn_fix(self, platform=None): self.Replace(ARFLAGS="q") def mySubProcess(cmdline, env): - startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW popen_args = { @@ -545,7 +540,6 @@ def mySubProcess(cmdline, env): return rv def mySpawn(sh, escape, cmd, args, env): - newargs = " ".join(args[1:]) cmdline = cmd + " " + newargs @@ -566,7 +560,6 @@ def mySpawn(sh, escape, cmd, args, env): def save_active_platforms(apnames, ap): - for x in ap: svg_names = [] if os.path.isfile(x + "/logo.svg"): @@ -594,7 +587,6 @@ def save_active_platforms(apnames, ap): def no_verbose(sys, env): - colors = {} # Colors are disabled in non-TTY environments such as pipes. This means @@ -708,7 +700,6 @@ def detect_visual_c_compiler_version(tools_env): # and for VS 2017 and newer we check VCTOOLSINSTALLDIR: if "VCTOOLSINSTALLDIR" in tools_env: - # Newer versions have a different path available vc_amd64_compiler_detection_index = ( tools_env["PATH"].upper().find(tools_env["VCTOOLSINSTALLDIR"].upper() + "BIN\\HOSTX64\\X64;") diff --git a/modules/denoise/resource_to_cpp.py b/modules/denoise/resource_to_cpp.py index 6c8327735599..a89eda91175f 100644 --- a/modules/denoise/resource_to_cpp.py +++ b/modules/denoise/resource_to_cpp.py @@ -19,9 +19,9 @@ import os from array import array + # Generates a C++ file from the specified binary resource file def generate(in_path, out_path): - namespace = "oidn::weights" scopes = namespace.split("::") diff --git a/platform/uwp/detect.py b/platform/uwp/detect.py index 64fe5bc4a2f9..03c4fd547ee6 100644 --- a/platform/uwp/detect.py +++ b/platform/uwp/detect.py @@ -21,7 +21,6 @@ def can_build(): if os.name == "nt": # building natively on windows! if os.getenv("VSINSTALLDIR"): - if os.getenv("ANGLE_SRC_PATH") is None: return False diff --git a/platform_methods.py b/platform_methods.py index 1a2520794cd9..ed0ab980d075 100644 --- a/platform_methods.py +++ b/platform_methods.py @@ -14,7 +14,6 @@ def run_in_subprocess(builder_function): @functools.wraps(builder_function) def wrapper(target, source, env): - # Convert SCons Node instances to absolute paths target = [node.srcnode().abspath for node in target] source = [node.srcnode().abspath for node in source] diff --git a/scene/resources/default_theme/default_theme_icons_builders.py b/scene/resources/default_theme/default_theme_icons_builders.py index 4dd5819a23eb..c4d132294c56 100644 --- a/scene/resources/default_theme/default_theme_icons_builders.py +++ b/scene/resources/default_theme/default_theme_icons_builders.py @@ -11,14 +11,12 @@ # See also `editor/icons/editor_icons_builders.py`. def make_default_theme_icons_action(target, source, env): - dst = target[0] svg_icons = source icons_string = StringIO() for f in svg_icons: - fname = str(f) icons_string.write('\t"') @@ -49,7 +47,6 @@ def make_default_theme_icons_action(target, source, env): index = 0 for f in svg_icons: - fname = str(f) # Trim the `.svg` extension from the string. diff --git a/scu_builders.py b/scu_builders.py index b26cfc77c046..5f7821655b39 100644 --- a/scu_builders.py +++ b/scu_builders.py @@ -45,7 +45,6 @@ def find_files_in_folder(folder, sub_folder, include_list, extension, sought_exc sub_folder_slashed = sub_folder + "/" for file in glob.glob("*." + extension): - simple_name = Path(file).stem if file.endswith(".gen.cpp"): @@ -62,7 +61,6 @@ def find_files_in_folder(folder, sub_folder, include_list, extension, sought_exc def write_output_file(file_count, include_list, start_line, end_line, output_folder, output_filename_prefix, extension): - output_folder = os.path.abspath(output_folder) if not os.path.isdir(output_folder): @@ -160,6 +158,7 @@ def find_section_name(sub_folder): # which is slow like a normal build, but prevents the naming conflicts. # Ideally in these situations, the source code should be changed to prevent naming conflicts. + # "extension" will usually be cpp, but can also be set to c (for e.g. third party libraries that use c) def process_folder(folders, sought_exceptions=[], includes_per_scu=0, extension="cpp"): if len(folders) == 0: @@ -243,7 +242,6 @@ def process_folder(folders, sought_exceptions=[], includes_per_scu=0, extension= def generate_scu_files(verbose, is_release_build): - print("=============================") print("Single Compilation Unit Build") print("=============================")