[FX] Refactor immutable collections implementation (#144640)

Get rid of dynamic class creation via `type(name, bases, ...)`. Convert it to classic static class definition for better readability and static analysis support.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/144640
Approved by: https://github.com/jansel
ghstack dependencies: #147699
This commit is contained in:
Xuehai Pan
2025-02-24 00:24:44 +08:00
committed by PyTorch MergeBot
parent dc9a03d30c
commit a50af71fb6
7 changed files with 84 additions and 75 deletions

View File

@ -3039,7 +3039,7 @@ class TestFX(JitTestCase):
from torch.fx.immutable_collections import immutable_list
x = immutable_list([3, 4])
with self.assertRaisesRegex(NotImplementedError, "new_args"):
with self.assertRaisesRegex(TypeError, "new_args"):
x[0] = 4
def test_partial_trace(self):