Browse Source

CI: Update static checks to black 23.3.0

And apply it to the codebase, removing empty lines at the start of blocks.
Rémi Verschelde 2 years ago
parent
commit
c9c941e339

+ 1 - 1
.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

+ 0 - 1
core/core_builders.py

@@ -239,7 +239,6 @@ def make_license_header(target, source, env):
             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")

+ 0 - 2
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)

+ 0 - 1
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:

+ 0 - 3
editor/editor_builders.py

@@ -14,7 +14,6 @@ from platform_methods import subprocess_main
 
 
 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")

+ 1 - 3
editor/icons/editor_icons_builders.py

@@ -8,16 +8,15 @@ import os
 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.

+ 0 - 7
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]

+ 0 - 2
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]
 

+ 0 - 9
methods.py

@@ -259,14 +259,11 @@ const char *const VERSION_HASH = "{git_hash}";
 
 
 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 use_windows_spawn_fix(self, platform=None):
         return rv
 
     def mySpawn(sh, escape, cmd, args, env):
-
         newargs = " ".join(args[1:])
         cmdline = cmd + " " + newargs
 
@@ -566,7 +560,6 @@ def use_windows_spawn_fix(self, platform=None):
 
 
 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;")

+ 1 - 1
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("::")
 

+ 0 - 1
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
 

+ 0 - 1
platform_methods.py

@@ -14,7 +14,6 @@ JSON_SERIALIZABLE_TYPES = (bool, int, float, str)
 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]

+ 0 - 3
scene/resources/default_theme/default_theme_icons_builders.py

@@ -11,14 +11,12 @@ from platform_methods import subprocess_main
 
 # 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.

+ 1 - 3
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("=============================")