Skip to content

Commit 17672f2

Browse files
committed
update for new ruff rules
1 parent 9581c1f commit 17672f2

File tree

8 files changed

+33
-24
lines changed

8 files changed

+33
-24
lines changed

trimesh/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@
8282

8383

8484
__all__ = [
85-
"PointCloud",
8685
"Geometry",
87-
"Trimesh",
86+
"PointCloud",
8887
"Scene",
8988
"Trimesh",
89+
"Trimesh",
9090
"__version__",
9191
"available_formats",
9292
"boolean",
@@ -103,8 +103,8 @@
103103
"graph",
104104
"grouping",
105105
"inertia",
106-
"iteration",
107106
"intersections",
107+
"iteration",
108108
"load",
109109
"load_mesh",
110110
"load_path",

trimesh/exchange/binvox.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ def voxel_from_binvox(rle_data, shape, translate=None, scale=1.0, axis_order="xz
201201
elif axis_order is None or axis_order == "xyz":
202202
encoding = encoding.reshape(shape)
203203
else:
204-
raise ValueError("Invalid axis_order '%s': must be None, 'xyz' or 'xzy'")
204+
raise ValueError(
205+
"Invalid axis_order '%s': must be None, 'xyz' or 'xzy'", axis_order
206+
)
205207

206208
assert encoding.shape == shape
207209

@@ -423,7 +425,7 @@ def __init__(
423425
)
424426

425427
if dimension > 1024 and not exact:
426-
raise ValueError("Maximum dimension using exact is 1024, got %d" % dimension)
428+
raise ValueError("Maximum dimension using exact is 1024, got %d", dimension)
427429
if file_type not in Binvoxer.SUPPORTED_OUTPUT_TYPES:
428430
raise ValueError(
429431
f"file_type {file_type} not in set of supported output types {Binvoxer.SUPPORTED_OUTPUT_TYPES!s}"
@@ -471,7 +473,7 @@ def __init__(
471473
times = np.log2(downsample_factor)
472474
if int(times) != times:
473475
raise ValueError(
474-
"downsample_factor must be a power of 2, got %d" % downsample_factor
476+
"downsample_factor must be a power of 2, got %d", downsample_factor
475477
)
476478
args.extend(("-down",) * int(times))
477479
if downsample_threshold is not None:

trimesh/exchange/gltf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1029,14 +1029,14 @@ def _build_accessor(array):
10291029
if vec_length > 4:
10301030
raise ValueError("The GLTF spec does not support vectors larger than 4")
10311031
if vec_length > 1:
1032-
data_type = "VEC%d" % vec_length
1032+
data_type = f"VEC{int(vec_length)}"
10331033
else:
10341034
data_type = "SCALAR"
10351035

10361036
if len(shape) == 3:
10371037
if shape[2] not in [2, 3, 4]:
10381038
raise ValueError("Matrix types must have 4, 9 or 16 components")
1039-
data_type = "MAT%d" % shape[2]
1039+
data_type = f"MAT{int(shape[2])}"
10401040

10411041
# get the array data type as a str stripping off endian
10421042
lookup = array.dtype.str.lstrip("<>")

trimesh/interfaces/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from . import blender, gmsh
22

33
# add to __all__ as per pep8
4-
__all__ = ["gmsh", "blender"]
4+
__all__ = ["blender", "gmsh"]

trimesh/typed.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,21 @@
6262
"Any",
6363
"ArrayLike",
6464
"BinaryIO",
65+
"Callable",
6566
"Dict",
67+
"Hashable",
6668
"Integer",
6769
"Iterable",
6870
"List",
6971
"Loadable",
72+
"Mapping",
7073
"NDArray",
7174
"Number",
7275
"Optional",
7376
"Sequence",
77+
"Set",
7478
"Stream",
7579
"Tuple",
7680
"float64",
7781
"int64",
78-
"Mapping",
79-
"Callable",
80-
"Hashable",
81-
"Set",
8282
]

trimesh/voxel/encoding.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -768,17 +768,20 @@ def __init__(self, encoding, shape):
768768
size = np.abs(size)
769769
if self._data.size % size != 0:
770770
raise ValueError(
771-
"cannot reshape encoding of size %d into shape %s"
772-
% (self._data.size, str(self._shape))
771+
"cannot reshape encoding of size %d into shape %s",
772+
self._data.size,
773+
str(self._shape),
773774
)
775+
774776
rem = self._data.size // size
775777
self._shape = tuple(rem if s == -1 else s for s in self._shape)
776778
elif nn > 2:
777779
raise ValueError("shape cannot have more than one -1 value")
778780
elif np.prod(self._shape) != self._data.size:
779781
raise ValueError(
780-
"cannot reshape encoding of size %d into shape %s"
781-
% (self._data.size, str(self._shape))
782+
"cannot reshape encoding of size %d into shape %s",
783+
self._data.size,
784+
str(self._shape),
782785
)
783786

784787
def _from_base_indices(self, base_indices):
@@ -818,9 +821,11 @@ def __init__(self, base_encoding, perm):
818821
raise ValueError(f"base_encoding must be an Encoding, got {base_encoding!s}")
819822
if len(base_encoding.shape) != len(perm):
820823
raise ValueError(
821-
"base_encoding has %d ndims - cannot transpose with perm %s"
822-
% (base_encoding.ndims, str(perm))
824+
"base_encoding has %d ndims - cannot transpose with perm %s",
825+
base_encoding.ndims,
826+
str(perm),
823827
)
828+
824829
super().__init__(base_encoding)
825830
perm = np.array(perm, dtype=np.int64)
826831
if not all(i in perm for i in range(base_encoding.ndims)):
@@ -898,7 +903,7 @@ def __init__(self, encoding, axes):
898903
super().__init__(encoding)
899904
if not all(0 <= a < self._data.ndims for a in axes):
900905
raise ValueError(
901-
"Invalid axes %s for %d-d encoding" % (str(axes), self._data.ndims)
906+
"Invalid axes %s for %d-d encoding", str(axes), self._data.ndims
902907
)
903908

904909
def _to_base_indices(self, indices):

trimesh/voxel/morphology.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def _sparse_indices(encoding, rank=None):
4242

4343
def _assert_rank(value, rank):
4444
if len(value.shape) != rank:
45-
raise ValueError("Expected rank %d, got shape %s" % (rank, str(value.shape)))
45+
raise ValueError("Expected rank %d, got shape %s", rank, str(value.shape))
4646

4747

4848
def _assert_sparse_rank(value, rank=None):
@@ -51,7 +51,7 @@ def _assert_sparse_rank(value, rank=None):
5151
if rank is not None:
5252
if value.shape[-1] != rank:
5353
raise ValueError(
54-
"sparse_indices.shape[1] must be %d, got %d" % (rank, value.shape[-1])
54+
"sparse_indices.shape[1] must be %d, got %d", rank, value.shape[-1]
5555
)
5656

5757

trimesh/voxel/runlength.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,9 @@ def sorted_rle_gather_1d(rle_data, ordered_indices):
390390
start += next(data_iter)
391391
except StopIteration:
392392
raise IndexError(
393-
"Index %d out of range of raw_values length %d" % (index, start)
393+
"Index %d out of range of raw_values length %d", index, start
394394
)
395+
395396
try:
396397
while index < start:
397398
yield value
@@ -533,8 +534,9 @@ def sorted_brle_gather_1d(brle_data, ordered_indices):
533534
start += next(data_iter)
534535
except StopIteration:
535536
raise IndexError(
536-
"Index %d out of range of raw_values length %d" % (index, start)
537+
"Index %d out of range of raw_values length %d", index, start
537538
)
539+
538540
try:
539541
while index < start:
540542
yield value

0 commit comments

Comments
 (0)