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

Update pre-commit with plugins that are compatible with python 3.12 #572

Merged
merged 2 commits into from
Nov 27, 2023
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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---
repos:
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.17.0
rev: v1.33.0
hooks:
- id: yamllint
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.11.0
hooks:
- id: black
files: ^Support/
language_version: python3
- repo: https://github.com/pycqa/flake8
rev: 3.9.0
rev: 6.1.0
hooks:
- id: flake8
files: ^Support/
- repo: https://github.com/PyCQA/pylint.git
rev: v2.15.5
rev: v3.0.1
hooks:
- id: pylint
name: pylint
Expand All @@ -32,7 +32,7 @@ repos:
hooks:
- id: dotnet-format
exclude: ^(Assets/ThirdParty)|(Packages/)
entry: dotnet-format whitespace
entry: dotnet format whitespace
args:
- --folder
- --include
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[MESSAGES CONTROL]
disable=bad-indentation,missing-class-docstring,missing-module-docstring,missing-function-docstring,invalid-name,fixme,line-too-long,duplicate-code,unspecified-encoding,consider-using-f-string,consider-using-with
disable=bad-indentation,missing-class-docstring,missing-module-docstring,missing-function-docstring,invalid-name,fixme,line-too-long,duplicate-code,unspecified-encoding,consider-using-f-string,consider-using-with,broad-exception-raised

extension-pkg-whitelist=math,zlib,struct
# Temporary, until https://github.com/PyCQA/pylint/issues/4297 is resolved
Expand Down
1 change: 1 addition & 0 deletions Support/Python/tbdata/glb.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ def _read_chunk(bf, expect_tag):
# Testing
#


# pylint: disable=all
# flake8: noqa
def load(version, name):
Expand Down
11 changes: 6 additions & 5 deletions Support/Python/tbdata/printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ def out_of_bounds(stroke):

def get_most_similar_factors(n):
"""Factorize n into two numbers.
Returns the best pair, in the sense that the numbers are the closest to each other."""
Returns the best pair, in the sense that the numbers are the closest to each other.
"""
i = int(n**0.5 + 0.5)
while n % i != 0:
i -= 1
Expand Down Expand Up @@ -507,7 +508,7 @@ def by_color_similarity(counter_pair):
# The sort used here only matters to humans when they look at the images
colors_and_counts = sorted(iter(counter.items()), key=by_color_similarity)
# colors_and_counts = sorted(counter.iteritems(), key=by_decreasing_usage)
for (color, count) in colors_and_counts:
for color, count in colors_and_counts:
colors_array[i : i + count] = color
i += count
colors_array.shape = (height, width, 3)
Expand Down Expand Up @@ -585,7 +586,7 @@ def get_imq_color(ipixel, data=imq.getdata(), palette=imq.getpalette()):
# Create table mapping unquantized rgb8 to quantized rgbaf
old_to_new = {}
idx = 0
for (old_color, group) in itertools.groupby(iter_rgb8(im)):
for old_color, group in itertools.groupby(iter_rgb8(im)):
assert old_color not in old_to_new
old_to_new[old_color] = rgb8_to_rgbaf(get_imq_color(idx))
idx += len(list(group))
Expand Down Expand Up @@ -619,7 +620,7 @@ def by_color(m):
return m.c[0]

meshes = iter_meshes(json_filename)
for (_, group) in itertools.groupby(sorted(meshes, key=by_color), key=by_color):
for _, group in itertools.groupby(sorted(meshes, key=by_color), key=by_color):
yield TiltBrushMesh.from_meshes(group)


Expand All @@ -629,7 +630,7 @@ def write_simple_obj(mesh, outf_name):
for v in mesh.v:
tmpf.write("v %f %f %f\n" % v)

for (t1, t2, t3) in mesh.tri:
for t1, t2, t3 in mesh.tri:
t1 += 1
t2 += 1
t3 += 1
Expand Down
3 changes: 2 additions & 1 deletion Support/Python/unitybuild/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class BuildFailed(Error):

class BadVersionCode(BuildFailed):
"""The Oculus store had a build with a code >= the one we uploaded.
self.desired_version_code is the lowest new version code that the store will accept."""
self.desired_version_code is the lowest new version code that the store will accept.
"""

def __init__(self, message, desired_version_code):
super().__init__(message)
Expand Down
11 changes: 6 additions & 5 deletions Support/Python/unitybuild/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def get_unity_exe(version, lenient=True):
exes = sorted(iter_editors_and_versions(), reverse=True)
if len(exes) == 0:
raise BuildFailed("Cannot find any Unity versions (want %s)" % (version,))
for (found_exe, found_version) in exes:
for found_exe, found_version in exes:
if found_version == version:
return found_exe

Expand Down Expand Up @@ -617,7 +617,7 @@ def get_exe_name(platform, exe_base_name):
full_version = "%s-%s" % (get_end_user_version(project_dir), stamp)

# Populate environment with secrets just before calling subprocess
for (env_var, credential_name) in required_credentials:
for env_var, credential_name in required_credentials:
if env_var not in cmd_env:
if is_jenkins:
# TODO(pld): Look into Jenkins plugins to get at these credentials
Expand Down Expand Up @@ -723,7 +723,7 @@ def iter_notice_files():
This software makes use of third-party software with the following notices.
"""
)
for (library_name, notice_file) in iter_notice_files():
for library_name, notice_file in iter_notice_files():
tmpf.write("\n \n=== %s ===\n" % library_name)
with open(notice_file) as inf:
contents = inf.read()
Expand Down Expand Up @@ -950,7 +950,7 @@ def main(

create_notice_file(project_dir)

for (platform, vrsdk, config) in iter_builds(args):
for platform, vrsdk, config in iter_builds(args):
stamp = revision + ("-exp" if args.experimental else "")
print(
"Building %s %s %s exp:%d signed:%d il2cpp:%d"
Expand Down Expand Up @@ -1008,7 +1008,7 @@ def main(
if args.for_distribution and vrsdk == "Oculus":
# .pdb files violate VRC.PC.Security.3 and ovr-platform-utils rejects the submission
to_remove = []
for (r, _, fs) in os.walk(output_dir):
for r, _, fs in os.walk(output_dir):
for f in fs:
if f.endswith(".pdb"):
to_remove.append(os.path.join(r, f))
Expand Down Expand Up @@ -1098,6 +1098,7 @@ def main(

# Tests


# This code seems rather temporary; ignore any and all warnings
# pylint: disable=all
# flake8: noqa
Expand Down
6 changes: 3 additions & 3 deletions Support/Python/unitybuild/refgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def _recreate_tb_stuff(self):
self.guid_to_name[command] = command

command_edges = list(tb.iter_command_edges(self.project_dir))
for (file_name, command) in command_edges:
for file_name, command in command_edges:
try:
file_guid = name_to_guid[file_name]
except KeyError:
Expand All @@ -167,10 +167,10 @@ def _finish(self):
self.name_to_guid = {}
# For convenience, also add lowercased-versions
# (but this is incorrect on case-sensitive filesystems)
for (g, n) in self.guid_to_name.items():
for g, n in self.guid_to_name.items():
self.name_to_guid[n.lower()] = g
# True capitalization takes precedence
for (g, n) in self.guid_to_name.items():
for g, n in self.guid_to_name.items():
self.name_to_guid[n] = g

# TILT BRUSH SPECIFIC:
Expand Down
6 changes: 3 additions & 3 deletions Support/Python/unitybuild/tb_refgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _get_command_lookup(project_dir):
assert re.match(r"^[a-zA-Z_]+$", v), "Doesn't look like an enum name: %r" % (v,)
to_index = {}
to_name = {}
for (i, v) in enumerate(vals):
for i, v in enumerate(vals):
for key in (v, v.lower(), i, str(i)):
to_index[key] = i
to_name[key] = v
Expand All @@ -42,14 +42,14 @@ def _get_command_lookup(project_dir):

def _iter_prefab_and_scene(project_dir):
pat = re.compile(r".*\.(unity|prefab)$")
for (r, _, fs) in os.walk(os.path.join(project_dir, "Assets")):
for r, _, fs in os.walk(os.path.join(project_dir, "Assets")):
for f in fs:
if pat.match(f):
yield os.path.join(r, f)


def _iter_cs(project_dir):
for (r, _, fs) in os.walk(os.path.join(project_dir, "Assets")):
for r, _, fs in os.walk(os.path.join(project_dir, "Assets")):
for f in fs:
if f.endswith(".cs"):
yield os.path.join(r, f)
Expand Down
6 changes: 3 additions & 3 deletions Support/Python/unitybuild/vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ def create():
git("status")
except subprocess.CalledProcessError:
return NullVcs()
else:
return GitVcs()
return GitVcs()


class VcsBase: # pylint: disable=too-few-public-methods
Expand Down Expand Up @@ -130,7 +129,8 @@ def get_build_stamp(self, input_directory): # pylint: disable=too-many-branches
<sha>
<sha>+<local changes>
<sha> is a sha of the lastest GoB commit included in the current build.
<local changes> is a tiny description of any changes in the build that aren't on GoB."""
<local changes> is a tiny description of any changes in the build that aren't on GoB.
"""
try:
status = git("status --porcelain", cwd=input_directory)
except subprocess.CalledProcessError as e:
Expand Down
4 changes: 2 additions & 2 deletions Support/bin/convert_gltf1.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def convert(
# Convert to pbr material
values = material.pop("values", {})
if "BaseColorFactor" in values:
for (guid, alpha_mode) in PBR_BRUSH_DESCRIPTORS:
for guid, alpha_mode in PBR_BRUSH_DESCRIPTORS:
if guid in vertex_shader_uri:
material["alphaMode"] = alpha_mode

Expand Down Expand Up @@ -290,7 +290,7 @@ def check_for_forbidden_values(value, forbidden, primitives=None):
if primitives is None:
primitives = set([int, int, float, str, str])
if type(value) in (dict, collections.OrderedDict):
for (k, v) in value.items():
for k, v in value.items():
# It's okay for the name to be in the forbidden list
if k != "name":
check_for_forbidden_values(v, forbidden)
Expand Down
13 changes: 6 additions & 7 deletions Support/bin/deobfuscate.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ def _get_section(self, name):
def _create_ob_to_syms(self):
# Create a simple aggregation of the lookup table
ob_to_syms = defaultdict(set)
for (_, section) in sorted(self.sections_by_name.items()):
for (ob, syms) in section.ob_to_syms.items():
for _, section in sorted(self.sections_by_name.items()):
for ob, syms in section.ob_to_syms.items():
ob_to_syms[ob] |= syms
self.ob_to_syms = dict(ob_to_syms)

Expand All @@ -160,11 +160,10 @@ def lookup(match):
if ob in COMMON_WORDS_11:
return ob
return "<? %s ?>" % ob
else:
short_syms = {ObfuscationSection.shorten(s) for s in syms}
if len(short_syms) == 1:
return short_syms.pop()
return "< " + " or ".join(sorted(syms)) + " >"
short_syms = {ObfuscationSection.shorten(s) for s in syms}
if len(short_syms) == 1:
return short_syms.pop()
return "< " + " or ".join(sorted(syms)) + " >"

pat = re.compile(r"\b[a-z]{11}\b")
return pat.sub(lookup, text)
Expand Down
1 change: 0 additions & 1 deletion Support/bin/find_unused.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def get_filesize(filename):


def main():

os.chdir(find_project_dir())
used = set(gen_used_assets(r"../Builds/Windows_SteamVR_Release/"))
exist = set(gen_existing_assets("."))
Expand Down
2 changes: 1 addition & 1 deletion Support/bin/jpg2png.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def main():
convert(arg)

if args.all_jpg:
for (r, _, fs) in os.walk("."):
for r, _, fs in os.walk("."):
for f in fs:
if f.endswith(".jpg"):
fullf = os.path.join(r, f)
Expand Down
1 change: 0 additions & 1 deletion Support/bin/tbdroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ def info(message):


def main():

parser = argparse.ArgumentParser()
parser.add_argument(
"--run", help="Run Tilt Brush on the remote device.", action="store_true"
Expand Down
Loading