Skip to content

Commit 8e0c82b

Browse files
bottlerfacebook-github-bot
authored andcommitted
lint fix: raise from None
Summary: New linter warning is complaining about `raise` inside `except`. Reviewed By: kjchalup Differential Revision: D37819264 fbshipit-source-id: 56ad5d0558ea39e1125f3c76b43b7376aea2bc7c
1 parent 8ba9a69 commit 8e0c82b

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

pytorch3d/datasets/r2n2/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def _read_binvox_header(f): # pragma: no cover
276276
try:
277277
dims = [int(d) for d in dims[1:]]
278278
except ValueError:
279-
raise ValueError("Invalid header (line 2)")
279+
raise ValueError("Invalid header (line 2)") from None
280280
if len(dims) != 3 or dims[0] != dims[1] or dims[0] != dims[2]:
281281
raise ValueError("Invalid header (line 2)")
282282
size = dims[0]
@@ -291,7 +291,7 @@ def _read_binvox_header(f): # pragma: no cover
291291
try:
292292
translation = tuple(float(t) for t in translation[1:])
293293
except ValueError:
294-
raise ValueError("Invalid header (line 3)")
294+
raise ValueError("Invalid header (line 3)") from None
295295

296296
# Fourth line of the header should be "scale [float]"
297297
line = f.readline().strip()

pytorch3d/implicitron/models/global_encoder/autodecoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def forward(self, x: Union[torch.LongTensor, List[str]]) -> Optional[torch.Tenso
107107
device=next(self.parameters()).device,
108108
)
109109
except StopIteration:
110-
raise ValueError("Not enough n_instances in the autodecoder")
110+
raise ValueError("Not enough n_instances in the autodecoder") from None
111111

112112
# pyre-fixme[29]: `Union[torch.Tensor, torch.nn.Module]` is not a function.
113113
return self._autodecoder_codes(x)

pytorch3d/implicitron/tools/stats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def update(self, preds, time_start=None, freeze_iter=False, stat_set="train"):
238238
"could not extract prediction %s\
239239
from the prediction dictionary"
240240
% stat
241-
)
241+
) from None
242242
else:
243243
val = None
244244

pytorch3d/io/off_io.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def _read_faces_lump(
8585
if n_faces > 1 and "Wrong number of columns" in e.args[0]:
8686
file.seek(old_offset)
8787
return None
88-
raise ValueError("Not enough face data.")
88+
raise ValueError("Not enough face data.") from None
8989

9090
if len(data) != n_faces:
9191
raise ValueError("Not enough face data.")
@@ -247,11 +247,11 @@ def _load_off_stream(file) -> dict:
247247
try:
248248
n_verts = int(items[0])
249249
except ValueError:
250-
raise ValueError("Invalid counts line: %s" % header)
250+
raise ValueError("Invalid counts line: %s" % header) from None
251251
try:
252252
n_faces = int(items[1])
253253
except ValueError:
254-
raise ValueError("Invalid counts line: %s" % header)
254+
raise ValueError("Invalid counts line: %s" % header) from None
255255

256256
if (len(items) > 3 and not items[3].startswith(b"#")) or n_verts < 0 or n_faces < 0:
257257
raise ValueError("Invalid counts line: %s" % header)

pytorch3d/io/ply_io.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def _parse_element(self, line: str):
236236
count = int(items[2])
237237
except ValueError:
238238
msg = "Number of items for %s was not a number."
239-
raise ValueError(msg % items[1])
239+
raise ValueError(msg % items[1]) from None
240240
self.elements.append(_PlyElementType(items[1], count))
241241

242242

@@ -409,12 +409,12 @@ def _parse_heterogeneous_property_ascii(datum, line_iter, property: _Property):
409409
else:
410410
datum.append(int(value))
411411
except ValueError:
412-
raise ValueError("Bad numerical data.")
412+
raise ValueError("Bad numerical data.") from None
413413
else:
414414
try:
415415
length = int(value)
416416
except ValueError:
417-
raise ValueError("A list length was not a number.")
417+
raise ValueError("A list length was not a number.") from None
418418
list_value = np.zeros(length, dtype=_PLY_TYPES[property.data_type].np_type)
419419
for i in range(length):
420420
inner_value = next(line_iter, None)
@@ -423,7 +423,7 @@ def _parse_heterogeneous_property_ascii(datum, line_iter, property: _Property):
423423
try:
424424
list_value[i] = float(inner_value)
425425
except ValueError:
426-
raise ValueError("Bad numerical data.")
426+
raise ValueError("Bad numerical data.") from None
427427
datum.append(list_value)
428428

429429

pytorch3d/ops/points_alignment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def iterative_closest_point(
141141
"(minibatch, dim, dim), T is a batch of dim-dimensional "
142142
"translations of shape (minibatch, dim) and s is a batch "
143143
"of scalars of shape (minibatch,)."
144-
)
144+
) from None
145145
# apply the init transform to the input point cloud
146146
Xt = _apply_similarity_transform(Xt, R, T, s)
147147
else:

0 commit comments

Comments
 (0)