From 88e182f989c80836f4bd744e0d9cb1852762ce01 Mon Sep 17 00:00:00 2001 From: generatedunixname89002005307016 Date: Tue, 29 Sep 2026 23:00:50 -0700 Subject: [PATCH] Suppress type errors for Pyre upgrade Summary: This diff was automatically generated by the Pyre per-target upgrade tool. It adds `# pyrefly: ignore` comments for type errors that an upcoming Pyrefly version will report. These suppressions keep existing type-checking tests passing while the upgrade rolls out. This diff changes comments only; it does not change Python runtime behavior or application logic. pyre-upgrade-september-29 #pyreupgrade Differential Revision: D122460195 fbshipit-source-id: 2ca62cd61e77d222c5b42ac89e73fc570a9781ae --- pytorch3d/implicitron/tools/eval_video_trajectory.py | 2 ++ pytorch3d/ops/points_alignment.py | 3 +++ pytorch3d/renderer/cameras.py | 4 ++++ pytorch3d/structures/meshes.py | 2 ++ pytorch3d/structures/pointclouds.py | 3 +++ 5 files changed, 14 insertions(+) diff --git a/pytorch3d/implicitron/tools/eval_video_trajectory.py b/pytorch3d/implicitron/tools/eval_video_trajectory.py index f46fe292..3556a305 100644 --- a/pytorch3d/implicitron/tools/eval_video_trajectory.py +++ b/pytorch3d/implicitron/tools/eval_video_trajectory.py @@ -182,10 +182,12 @@ def generate_eval_video_cameras( ) test_cameras = PerspectiveCameras( + # pyrefly: ignore [bad-argument-type] focal_length=focal_length, principal_point=principal_point, R=R, T=T, + # pyrefly: ignore [missing-attribute] device=focal_length.device, ) diff --git a/pytorch3d/ops/points_alignment.py b/pytorch3d/ops/points_alignment.py index 1ae50cdb..94db8687 100644 --- a/pytorch3d/ops/points_alignment.py +++ b/pytorch3d/ops/points_alignment.py @@ -340,8 +340,11 @@ def corresponding_points_alignment( total_weight = torch.clamp(num_points, 1) # special handling for heterogeneous point clouds and/or input weights if weights is not None: + # pyrefly: ignore [bad-index] Xc *= weights[:, :, None] + # pyrefly: ignore [bad-index] Yc *= weights[:, :, None] + # pyrefly: ignore [missing-attribute] total_weight = torch.clamp(weights.sum(1), eps) if (num_points < (dim + 1)).any(): diff --git a/pytorch3d/renderer/cameras.py b/pytorch3d/renderer/cameras.py index 16e7a496..8039f0d4 100644 --- a/pytorch3d/renderer/cameras.py +++ b/pytorch3d/renderer/cameras.py @@ -427,9 +427,11 @@ class CamerasBase(TensorProperties): if isinstance(index, tensor_types["bool"]): # LongTensor]` has no attribute `ndim`. # LongTensor]` has no attribute `shape`. + # pyrefly: ignore [missing-attribute] if index.ndim != 1 or index.shape[0] != len(self): raise ValueError( # LongTensor]` has no attribute `shape`. + # pyrefly: ignore [missing-attribute] f"Boolean index of shape {index.shape} does not match cameras" ) elif max(index) >= len(self): @@ -1790,11 +1792,13 @@ def get_ndc_to_screen_transform( image_size = torch.tensor(image_size, device=cameras.device) # pyrefly: ignore [missing-attribute] image_size = image_size.view(-1, 2) # of shape (1 or B)x2 + # pyrefly: ignore [missing-attribute] height, width = image_size.unbind(1) # For non square images, we scale the points such that smallest side # has range [-1, 1] and the largest side has range [-u, u], with u > 1. # This convention is consistent with the PyTorch3D renderer + # pyrefly: ignore [missing-attribute] scale = (image_size.min(dim=1).values - 0.0) / 2.0 K[:, 0, 0] = scale diff --git a/pytorch3d/structures/meshes.py b/pytorch3d/structures/meshes.py index 07acece0..d1f1c85e 100644 --- a/pytorch3d/structures/meshes.py +++ b/pytorch3d/structures/meshes.py @@ -510,7 +510,9 @@ class Meshes: index = index.squeeze(1) if index.numel() > 0 else index # pyrefly: ignore [missing-attribute] index = index.tolist() + # pyrefly: ignore [not-iterable] verts = [self.verts_list()[i] for i in index] + # pyrefly: ignore [not-iterable] faces = [self.faces_list()[i] for i in index] else: raise IndexError(index) diff --git a/pytorch3d/structures/pointclouds.py b/pytorch3d/structures/pointclouds.py index 53ed5a51..16505e54 100644 --- a/pytorch3d/structures/pointclouds.py +++ b/pytorch3d/structures/pointclouds.py @@ -411,10 +411,13 @@ class Pointclouds: index = index.squeeze(1) if index.numel() > 0 else index # pyrefly: ignore [missing-attribute] index = index.tolist() + # pyrefly: ignore [not-iterable] points = [self.points_list()[i] for i in index] if normals_list is not None: + # pyrefly: ignore [not-iterable] normals = [normals_list[i] for i in index] if features_list is not None: + # pyrefly: ignore [not-iterable] features = [features_list[i] for i in index] else: raise IndexError(index)